0

unsigned char x=300; printf("%d",x);

Output is 44 anyone explain why?

22nd Aug 2020, 8:41 AM
Rohit Ahuja
Rohit Ahuja - avatar
2 Answers
+ 4
unsigned char has a range of 256 integer values from 0 through 255. Setting x to 300 causes an overflow and the value wraps around by the remaining amount. 300 - 256 = 44
22nd Aug 2020, 8:49 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Thnx
22nd Aug 2020, 10:58 AM
Rohit Ahuja
Rohit Ahuja - avatar