Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 68

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 80

Answer:

main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}


Answer:
10


Explanation:
The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i is still allocated space, *j prints the value stored in i since j points i.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 68 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: