Hi, Please see the below code and help me understand why an out of range value is displayed here. #include<conio.h> #include<stdio.h> main() { int sum=32768; printf("%d",sum); } output = 32768 Since sum is an integer, its range is -32767 to 32768 and it is not defined as an unsigned integer. But why the output is 32768.
What is your OS? A signed integer occupies 2 bytes of memory in Windows. Another thing, the correct range is: -32768 to 32767. (It only seems to be a typing mistake according to your question.)
It is known that different application software allow different ranges of the data type int. There are application software, in which the range is -32768 to 32767, and in some, is -2148473648 to +2148473647. From my point of view, your application software has the range of 4bytes, and therefore, showing you the result that you consider wrong, but is true actually. To check, change the value of your variable into 2148473678. You will get your answer. Hoping you got your answer. Thanks