Make your own free website on Tripod.com

program The student height;
uses wincrt;
var
student_num, j, tallest, shortest : integer;
height : array[1..40] of integer;
procedure student_number;
begin
repeat
write('How many students do your class have(1-40) ?');
readln(student_num);
if (student_num < 0) or (student_num > 40)
then writeln('Wrong number!');
until (student_num > 1) and (student_num < 40);
writeln(chr(7));
writeln;
end;
procedure student_height;
begin
for j := 1 to student_num do
repeat
write('Height of student',j,'(>0)?');
readln(height[j]);
if height[j] < 0
then writeln('Wrong height!');
writeln;
until height[j] > 0
end;
procedure tallest_student;
begin
tallest := 1;
for j := 2 to student_num do
if height[j] > height[tallest]
then tallest := j;
writeln('The tallest student is student', tallest,', height = ',height[tallest]);
writeln(chr(7));
end;
procedure shortest_student;
begin
shortest := 1;
for j := 2 to student_num do
if height[j] < height[shortest]
then shortest := j;
writeln('The shortest student is student', shortest,', height = ',height[shortest]);
writeln(chr(7));
end;
begin{main program}
student_number;
student_height;
tallest_student;
shortest_student
end.