89.9k views
4 votes
Write a program in Pascal and pseudocode to enter marks of a student terminated by 999. Find the average and highest mark.

User Mgilbert
by
8.5k points

1 Answer

4 votes

Final answer:

To write a program in Pascal and pseudocode to enter marks of a student terminated by 999 and find the average and highest mark, you can use the following algorithm: Declare variables for the marks, highest mark, and sum of marks. Initialize the highest mark variable to 0 and the sum of marks variable to 0. Start a loop that continues until the student enters 999. Within the loop, prompt the student to enter a mark. If the entered mark is higher than the current highest mark, update the highest mark variable. Add the entered mark to the sum of marks. Continue the loop until the student enters 999. After the loop ends, calculate the average by dividing the sum of marks by the number of entered marks. Display the average and highest mark.

Step-by-step explanation:

To write a program in Pascal and pseudocode to enter marks of a student terminated by 999 and find the average and highest mark, you can use the following algorithm:

  1. Declare variables for the marks, highest mark, and sum of marks.
  2. Initialize the highest mark variable to 0 and the sum of marks variable to 0.
  3. Start a loop that continues until the student enters 999.
  4. Within the loop, prompt the student to enter a mark.
  5. If the entered mark is higher than the current highest mark, update the highest mark variable.
  6. Add the entered mark to the sum of marks.
  7. Continue the loop until the student enters 999.
  8. After the loop ends, calculate the average by dividing the sum of marks by the number of entered marks.
  9. Display the average and highest mark.

Here's an example of the program in Pascal:

program CalculateMarks;
var
mark, highestMark, sum, count: integer;
average: real;
begin
count := 0;
sum := 0;
highestMark := 0;
repeat
write('Enter a mark (or 999 to terminate): ');
readln(mark);
if mark <> 999 then
begin
if mark > highestMark then
highestMark := mark;
sum := sum + mark;
count := count + 1;
end;
until mark = 999;
average := sum / count;
writeln('Average mark: ', average:0:2);
writeln('Highest mark: ', highestMark);
end.
User Jonathan Perry
by
6.9k points