initial import
[staff/goc4/2018bti7061.git] / c-1-basics / examples / fundamentalsC / constants2.c
1 #include <stdio.h>
2
3 main(){
4
5
6 char c1 = 'A';
7 char c2 = 'c';
8 char c3 = '0';
9 char c4 = '?';
10 char c5 = '\n';
11
12 printf("c1 as char = %c, as digital =%d, as hexa=%x\n",c1,c1,c1);
13 printf("c2 as char = %c, as digital =%d, as hexa=%x\n",c2,c2,c2);
14 printf("c3 as char = %c, as digital =%d, as hexa=%x\n",c3,c3,c3);
15 printf("c4 as char = %c, as digital =%d, as hexa=%x\n",c4,c4,c4);
16 printf("c5 as char = %c, as digital =%d, as hexa=%x\n",c5,c5,c5);
17
18 // Examples for variables declaration and initializations
19 // Integers and double precition floating numbers
20 int a, b, c;
21 double d1, d2, d3;
22 a=100;
23 b=0;
24 c=0x100;
25 d1=5.0;
26 d2=4E3;
27 d3=d1+d2*c;
28 printf("d3 = %f\n",d3);
29
30 a=200;
31 a=2*a+b*c;
32
33 // Examples of chars
34 char ch1, ch2;
35 ch1='4';
36 ch2='A';
37 char ch3 = '\n';
38
39 // And strings (arrays of chars)
40 char str1[80];
41 char str2[]="Biel / Bienne";
42
43 char str3[10]="Ville de Bienne";
44 char str4[]="Tooto\n";
45
46 printf("Hello %s%c",str2,ch3); // Inserts a \n after the city name
47 printf("Hello %s",str3); //
48
49
50 // Be carreful to reserve enough space
51
52
53
54 }