Mayank's C/C++ Challenger - IV
Kindly excuse my prolong absence from the forum. Here comes our own quite old C/C++ Challenger, with another not very great but a bit mind twisting C/C++ puzzle.
So It goes as:
Write an efficient way to print 32 bitwise representation of an integer exactly as stored in the memory[O/p should be in Binary]. Make sure the Output of your program should differ if it is made to run on different hardwares.[One supporting Little Endian eg: Intel and another Supporting Big Endian eg: SPARC format]. If required, you can have the flexibility to use integer size of 16 bit instead of 32 bit.
Example:
[For 32 bit Integer]
I/P: 5
O/P:
Big Endian:
00000000000000000000000000000101
Little Endian:
00000101000000000000000000000000
Regards,
Mayank Shukla