Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 150

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

Answer:

main()
{
int i=300;
char *ptr = &i;
*++ptr=2;
printf("%d",i);
}


Answer:
556


Explanation:
The integer value 300 in binary notation is: 00000001 00101100. It is stored in memory (small-endian) as: 00101100 00000001. Result of the expression *++ptr = 2 makes the memory representation as: 00101100 00000010. So the integer corresponding to it is 00000010 00101100 => 556.

Share: 
 

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


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


Tagged: