-
Notifications
You must be signed in to change notification settings - Fork 14
/
c9.txt
60 lines (52 loc) · 1.06 KB
/
c9.txt
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
**Code Generation test case 9: Switch Case statement with for loop
Single driver module with multiple levels of nesting
Variant of test case 8
**
<<<driver program>>>
start
declare x, y, z:integer;
declare b: boolean;
declare loop_var:integer;
y:= 19;
z:= 56;
for(loop_var in 3..6)
start
get_value(x);
switch(x)
start
case 1: y:= x*2-y+loop_var;
print(y);
break;
case 2: z:= x*3-z+loop_var;
print(z);
break;
default:print(x);
break;
end
print(y);
print(z);
end
end
** On the console [Reading via loop 4 values of x iteratively - 2, 1, 2 and 3 in 4 iterations]
Input: Enter an integer value
2
Output: -47
Output: 19
Output: -47
Input: Enter an integer value
1
Output: -13
Output: -13
Output: -47
Input: Enter an integer value
2
Output: 58
Output: -13
Output: 58
Input: Enter an integer value
3
Output: 3
Output: -13
Output: 58
Similarly run the generated assembly code for other input values and verify.
**