What should be the output of the program and why?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What should be the output of the program and why??

According to me hello should print but output is world. https://code.sololearn.com/ckK1ZJp41hjL/?ref=app

28th Jan 2020, 7:20 AM
Prakhar
2 Answers
+ 4
C does implicit type casting in this case. Since you can't compare between unsigned and signed integers directly C must to decide which one to use. If it decides to use unsigned values the -23 is seen to a much larger positive value because unsigned values can't be negative and are interpreted differently. To avoid such weird behaviour you should only compare the same data types.
28th Jan 2020, 7:42 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
line no 4. ->signed int i=23; not->unsigned int i=23;
29th Jan 2020, 8:58 AM
ISTIAQUE ZAMAN
ISTIAQUE ZAMAN - avatar