Any explanation ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Any explanation ?!

Way this code print 44 ? #include <stdio.h> int main (){ char x = 300; printf ("%d",x); and print 30 when x assigned to the value 30 ?

26th May 2021, 3:42 AM
Awab Ibrahim
Awab Ibrahim - avatar
1 Answer
0
You have assigned a integer to a char type, a integer is 4 bytes in size while a char is only 1. This will cause a overflow.
25th Oct 2022, 3:00 AM
Sickfic
Sickfic - avatar