-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtestcase2.txt
60 lines (51 loc) · 1.59 KB
/
testcase2.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
%Test Case 2
%Following program computes the average marks obtained by students in three subjects
%Following function reads marks of a student in all subjects and returns as a record variable
% Note that the variable b7 is not used anywhere but it is the syntactic requirement to have
% atleast one input parameter
_addRecords input parameter list[int b2, record #marks c3b5, record #marks c3b6]
output parameter list [ record #marks b3c45];
[c3b5] <---call _readMarks with parameters [b2];
[c3b6]<---call _readMarks with parameters [b2];
b3c45 <--- c3b5 + c3b6;
return [b3c45];
end
_readMarks input parameter list[int b7]
output parameter list [ record #marks b3c2];
read(b3c2.maths);
read(b3c2.physics);
read(b3c2.chemistry);
return [b3c2];
end
%The following program computes the average of marks of total d5cb34567 students
_main
record #marks
type real : maths;
type real: physics;
type real: chemistry;
endrecord;
% each field above represents the marks obtained in corresponding subject
type record #marks : d4;
% The variable d4 stores the marks of one student
type int : b5;
type int : d5cb34567;
type real : b5;
type record #marks : b5c6;
%The identifier b5c6 stores the sum of marks
b5 <--- 1;
read(d5cb34567);
b5c6.maths <--- 0.00;
b5c6.physics <--- 0.00;
b5c6.chemistry <---0.00;
while(b5<=d5cb34567)
[d4] <--- call _readMarks with parameters [b5];
[b5c6] <--- call _addRecords with parameters [b5c6];
% above displays the sum of records
b5 <--- b5 +1;
endwhile
d4 <--- b5c6 / d5cb34567;
write(d4.maths);
write(d4.physics);
write(d4.chemistry);
return;
end