0

Can someone help me to understand this code ↓ ?

// Why this output ?? #include <stdio.h> #include<stdlib.h> int main (){ unsigned char x =300; printf("%d",x); return 0; } //Output : 44

21st Feb 2022, 1:51 AM
Mik
Mik - avatar
11 Answers
+ 2
FF9900 it just output 44 is for what i hoped to show 300
21st Feb 2022, 1:57 AM
Mik
Mik - avatar
+ 2
44
21st Feb 2022, 2:05 AM
Mik
Mik - avatar
+ 2
It given the overflow number instend of the rest
21st Feb 2022, 2:06 AM
Mik
Mik - avatar
+ 2
Where going the 256 bits rest so
21st Feb 2022, 2:12 AM
Mik
Mik - avatar
+ 1
Mik_RDC unsigned char is from 0 to 255. Go over that and it starts from 0 again. so 256 = 0, 257=1... 300=44.
22nd Feb 2022, 1:02 PM
Bob_Li
Bob_Li - avatar
+ 1
You declared a char type but assigned it an int type... Therefore unsigned conversion of int to unsigned conversion to char outputs a number your case 44
23rd Feb 2022, 10:35 AM
Dennis Kimathi
Dennis Kimathi - avatar