Skip to main content

Posts

Showing posts from November, 2012

Some interesting questions

1.whats the value of x. x = 20; y=30; x=y++ + x++; x = 30++ + 20 ++ = 50 but there is one ++ pending for x which shall be executed so the value of x will 51 . 2.write  a function to check its a big endian or little endian first method union test{         int i;         char c; }; test t1; t1.i = 1; if(t1.c == 1){     pf("LE"); } else pf("BE"); second method. int i=1; if( *(char*)&i == 1) pf("LE"); else pf("BE") 3.write a program to reverse the bits in an integer 1101 ==> 1011  int output; for(int i=0;i<32;i++){        if( input & 1 ==1 ){              output |= 1<<32-i;        }      input = input >> 1; } 4.  int inc(int ip){      static int i=2;      i += ip;      return i; } x = 10; if(  inc(x) == 12 || inc(x) == 14 ) pf("%d",inc(10)) ; whats is the output?  its quite easy .. let me know if u need answer. 5.Think about the reason for one thread not rec