The shortest code to tell if a number is even or odd One of my colleagues proposed us a challenge: to write the shortest C/C++ program to determine if a number is even or odd.

These are the requirements:


Get a number from keyboard, at run-time (not from command line)
Output the string pari if the number is even
Output the string dispari if the number is odd
We can assume that the input is legal
We can assume that the machine has a i386 architecture
Code preprocessing is not allowed (e.g.: use #defines)
[edit after comments] The code can be considered valid if it compiles with gcc 4.x


This is the best attempt we had so far (file test.c, 50B):

main(i){scanf("%d",&amp;i);puts("dispari"+3*(~i&amp;1));}


Do you think we can go further?

(*): "dispari" is the italian for odd and "pari" is the italian for even
47 bytes (2 less)

main(i){scanf("%d",&amp;i);puts("dispari"-~i%2*3);}


For a positive i, ~i is negative, so ~i%2 is 0 or -1.