0

Why does this Code prints "No"

#include <stdio.h> int main() { unsigned int i=23; signed char c=-23; if(i>c) printf("Yes"); else if(i<c) printf("No"); }

6th Nov 2018, 2:19 PM
Adi Citta Agitsha Justitio
Adi Citta Agitsha Justitio - avatar
2 Respuestas
+ 3
jagitsha2 When you compare unsigned and signed types, compiler convert signed variable to unsigned, but because representation of number in memory (see complement two on google) negative numbers (casted to unsigned) would be "valuted" much larger that you think i repeat, search for complement to two on google and you will understand
6th Nov 2018, 3:10 PM
KrOW
KrOW - avatar
0
Can you tell me the reason for using signed char. What are you expecting by assigning negative value to char variable.
6th Nov 2018, 2:59 PM
Mukul
Mukul - avatar