In which format does C store an integer in main memory of the computer (RAM).(Given that is uses two bytes for integer datatype)
In which format does C store an integer in main memory of the computer (RAM).(Given that is uses two bytes for integer datatype)
The endianness depends on the CPU. For instance, the low order byte first, then the high order next on an intel architecture.
The representation in memory of an integer (in fact, of any type) is implementation dependent. It varies between compilers, host systems, etc.
Also, it is implementation dependent whether an integer datatype is sized at two bytes. Four bytes is also common in practice.
In binary
You used the word "which", implying that there were was a common understanding of the options from which to pick from. However, you'd need to supply those options in this case.
If you were talking about endianness, then that isn't determined by the C language; It's determined by the system that the code is compiled for.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"