/* * types.c * * Created on: Mar 12, 2014 * Author: carola */ #include #include void numberTypeTable(){ /* Negative numbers: -> two's complement * http://en.wikipedia.org/wiki/Two%27s_complement */ /*unsigned char c;*/ char c; short s; int i; long l; printf(" char short int long\n"); printf("bytes %4d %6d %11d %21ld\n", sizeof(c), sizeof(s), sizeof(i), sizeof(l)); printf(" ==== ====== =========== =====================\n"); c = s = i = l = 1; while (l>0){ c *= 2; s *= 2; i *= 2; l *= 2; printf(" %4d %6d %11d %21ld\n", c, s, i, l); } } int main(){ char c = 'a'; printf("c=%c\n",c); // printing as a character printf("c=%d\n",c); // printing as an integer int i=c; printf("i=%d\n",i); // printing as an integer double x=5.7; i=x; printf("i=%d\n",i); // printing as an integer printf("\n\nNow printing numberTypeTable:\n"); numberTypeTable(); return 0; }