windows - C. Why does it equal 1? -


so i'm reading book. i'm using gcc, , when ever compile code print 1.

int x = 5, y = 3; printf("%d", x > 3); 

the result 1. if did:

int = 3, j = 4, k = 5; printf("%d", % j + < k); 

can explain i'm doing wrong?

edit: if

 int = 10, j = 1; printf("%d", > j ? : j); 

that print out 10.

because you're doing comparison, , comparisons true, 1 in decimal. (0 being false).

hth


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -