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

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -