PROGRAM THIRTEEN
Given the following marks achieved in a programming test, and that the pass mark is the average of all the marks, write a program to list those students who have passed.
 FRED		21	GEORGE		56
 ANNE		52	MARY		89
 ROBERT		71	ALFRED		71
 CECIL		33	MIKE		54
 JENNIFER	41	PAULINE		48


	program PROG13 (output);
	const   maxstudents = 10;
	type    namestr = PACKED ARRAY [1..20] of char;
	var     NAME : ARRAY [1..10] of namestr;
	        mark : ARRAY [1..10] of integer;
	        totalmarks, loopcount : integer;
	        averagemk  : real;
	begin
	     NAME[1] := 'FRED                ';   MARK[1] := 21;
	     NAME[2] := 'GEORGE              ';   MARK[2] := 56;
	     NAME[3] := 'ANNE                ';   MARK[3] := 52;
	     NAME[4] := 'MARY                ';   MARK[4] := 89;
	     NAME[5] := 'ROBERT              ';   MARK[5] := 71;
	     NAME[6] := 'ALFRED              ';   MARK[6] := 71;
	     NAME[7] := 'CECIL               ';   MARK[7] := 33;
	     NAME[8] := 'MIKE                ';   MARK[8] := 54;
	     NAME[9] := 'JENNIFER            ';   MARK[9] := 41;
	     NAME[10] := 'PAULINE             ';  MARK[10] := 48;

	     { find totalmarks first }
	     totalmarks := 0;
	     for loopcount := 1 to maxstudents do
	        totalmarks := totalmarks + mark[loopcount];

	     { calculate average mark }
	     averagemk := totalmarks / maxstudents;

	     { display those who have passed }
	     writeln('The students who passed the test are ');
	     for loopcount := 1 to maxstudents do
	       if mark[loopcount] >= averagemk then
	           writeln(NAME[loopcount]);
	     writeln;
	     writeln('The average mark was ',averagemk:2:2)
	end.


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.