-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatements.c
77 lines (61 loc) · 1.42 KB
/
statements.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>
int main() {
int x = 10;
int y = 3;
int severity = 3;
int i = 0, j = 5, k, l, m, n = 0;
if (x > y) {
printf("%d is greater than %d", x, y);
} else if (x < y) {
printf("%d is smaller than %d", x, y);
} else {
printf("%d is equal with %d", x, y);
}
printf("\n-----------\n");
(x > y) ? printf("%d is greater than %d (ternary)\n", x, y) : printf("%d is smaller than %d", x, y);
switch (severity) {
case 1:
printf("Low\n");
break;
case 2:
printf("MEDIUM\n");
break;
case 3:
printf("HIGH\n");
break;
default:
printf("No data\n");
}
while (i < 5) {
printf("%d\n", i);
i++;
}
printf("---------\n");
do {
printf("%d\n", j);
j--;
} while (j > 0);
printf("---------\n");
for (k = 0; k < 5; k++) {
printf("%d\n", k);
}
printf("---------\n");
// Outer loop
for (l = 1; l <= 2; ++l) {
printf("Outer: %d\n", l); // Executes 2 times
// Inner loop
for (m = 1; m <= 3; ++m) {
printf(" Inner: %d\n", m); // Executes 6 times (2 * 3)
}
}
printf("---------\n");
while (n < 10) {
if (n == 4) {
n++;
continue;
}
printf("%d\n", n);
n++;
}
return 0;
}