initial import
[staff/goc4/2018bti7061.git] / c-1-basics / examples / fundamentalsC / constants.c
1 #include <stdio.h>
2
3 main(){
4
5 int i1 = 12345;
6 int i2 = 0;
7 int i3 = -145;
8 int i4 = 234;
9 puts("Integer values");
10 printf("i1 = %d, i2=%d, i3=%d, i4=%d\n",i1,i2,i3,i4);
11
12 int j1 = 0;
13 int j2 = 017;
14 int j3 = 07777;
15 printf("j1 = %d, j2=%d, j3=%d\n",j1,j2,j3);
16 /* Output: j1 = 0, j2=15, j3=4095 */
17
18 int k1 = 0xA;
19 int k2 = 0x10;
20 int k3 = -0xFFFF;
21 int k4 = 0x10000;
22
23 printf("k1 = %d, k2=%d, k3=%d, k4=%d\n",k1,k2,k3,k4);
24 /* Output: k1 = 10, k2=16, k3=-65535, k4=65536 */
25
26 puts("(or written in hexadecimal):");
27 printf("k1 = %x, k2=%x, k3=%x, k4=%x\n",k1,k2,k3,k4);
28 /* Output: k1 = a, k2=10, k3=ffff0001, k4=10000 */
29
30 /* Largest integer */
31 int k5 = 0x7FFFFFFF;
32 /* Smallest integer */
33 int k6 = 0x80000000;
34 printf("MAXINT= %x, (%d),MININT=%x,(%d) \n",k5,k5,k6,k6);
35
36 long l1 = 10;
37 long l2 = -20;
38 long l3 = 0xFFFFFFFFFFF;
39 printf("l1 = %ld, l2=%ld, l3=%ld\n",l1,l2,l3);
40
41 unsigned long ul1 = 0xFFFFFFFFFFFFFFFF;
42 long l4=-1;
43 printf("ul1 = %ld, l4=%ld\n",ul1,l4);
44 printf("ul1 = %lu, l4=%lu\n",ul1,l4);
45 printf("ul1 = %lx, l4=%lx\n",ul1,l4);
46 /* Output : ul1 = -1, l4=-1 */
47
48
49
50
51
52 }