Skip to main content

Posts

Showing posts with the label tricky

C advanced interview questions and answers

   C advanced interview questions and answers  (1) What will be output if you will compile and execute the following c code? struct   marks {   int   p :3;   int   c :3;   int   m :2; }; void   main (){   struct   marks  s={2,-6,5};   printf( "%d %d %d" ,s. p ,s. c ,s. m );   } (a) 2 -6 5 (b) 2 -6 1 (c) 2 2 1 (d) Compiler error (e) None of these Answer:  (c) Explanation: Binary value of 2: 00000 010  (Select three two bit) Binary value of 6: 00000110 Binary value of -6: 11111001+1=11111 010 (Select last three bit) Binary value of 5: 000001 01  (Select last two bit) Complete memory representation: (2) What will be output if you will compile and execute the following c code? void   main (){    int  huge*p=( int  huge*)0XC0563331;    int  huge*q=( int  huge*)0xC2551341;   ...