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


1/28/2020 7:20:40 AM


3 Answers

New Answer


When you try compare signed and unsigned, the compiler converts signed to unsigned, then... https://code.sololearn.com/csLVpZLN2j0H/?ref=app


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.


line no 4. ->signed int i=23; not->unsigned int i=23;