+ 8
[SOLVED]Explain the output?
Why the code gives output no instead of yes. Why unsigned and signed makes difference https://code.sololearn.com/c83m2NYwj8Pv/?ref=app
5 Respostas
+ 14
Omkar Jadhav because -20 made unsigned is 4294967276 so much larger than 24. Mixing signed and unsigned always results in auto conversion to unsigned.
+ 6
John Wells sir maybe you can answer my question
+ 5
Yes the signed integer is implicitly cast to an unsigned (large positive number) during the comparison with an unsigned integer.
0
If we mixed signed and unsigned int in the program then it can create issues because as per the c standard if we perform the arithmetic operation on signed and unsigned number then the resultant value can be implementation dependent or undefined in some scenarios.
In C99, integer promotion is clearly defined that If an int can represent all values of the original type, the value is converted to an int, otherwise, it is converted to an unsigned int.