Computer Science – 10.2 Arrays | e-Consult
10.2 Arrays (1 questions)
Login to see all questions.
Click on a question to view the answer
Pseudo-code:
- Input: An array of 5 numerical values representing student marks (e.g., marks[0], marks[1], marks[2], marks[3], marks[4]).
- Initialize:
-
total_markto 0 -
highest_markto a very low number (e.g., -9999) -
highestmarkindexto -1 (indicating no highest mark found yet)
-
- Calculate Total Mark:
- For each mark in the
marksarray:- Add the current mark to
total_mark.
- Add the current mark to
- For each mark in the
- Calculate Average Mark:
- Calculate
averagemarkby dividingtotalmarkby 5.
- Calculate
- Find Highest Mark:
- For each mark in the
marksarray:- If the current mark is greater than
highest_mark:- Set
highest_markto the current mark. - Set
highestmarkindexto the current index.
- Set
- If the current mark is greater than
- For each mark in the
- Output:
- Display the
average_mark. - Display the student with the highest mark (e.g., "Student at index {highestmarkindex} with mark {highest_mark}").
- Display the