Multiple choice

What will be the output of the following C code? void main() { int a; char *pr; int Num=288; pr=(char *)&Num; for(a=0;a<2;a++) printf(%d ,*pr++); }

  1. 288 0

  2. 32 1

  3. 0 1

  4. Compilation error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C int, datatype is of 2 bytes while char pointer pt will take only one byte. Binary representation of 32 is 00000000 00100000.  The pr pointer will first point the second byte, and then the first byte. So, second byte will be represented by 00100000, i.e. 32 and first byte will be represented by 00000000, i.e. 0. Hence, the output will be 32 0.