Information Technology IT – 4 Algorithms and flowcharts | e-Consult
4 Algorithms and flowcharts (1 questions)
Login to see all questions.
Click on a question to view the answer
Algorithm:
- Start
- Get the number of students (
num_students) from thescoresarray. - Calculate the sum of all scores:
totalscore = 0. Iterate through thescoresarray, adding each score tototalscore. - Calculate the average score:
averagescore = totalscore / num_students. - Initialize an empty list called
aboveaveragestudents. - Iterate through the
scoresarray again. For each score:- If the current score is greater than
average_scorethen:- Add the student's index (or identifier) to the
aboveaveragestudentslist.
- Add the student's index (or identifier) to the
- If the current score is greater than
- Output:
averagescoreandaboveaverage_students.
Pseudocode:
START
INPUT scores (array)
INPUT num_students (length of scores)
total_score = 0
FOR i = 1 TO num_students DO
totalscore = totalscore + scores[i]
END FOR
averagescore = totalscore / num_students
aboveaveragestudents = []
FOR i = 1 TO num_students DO
IF scores[i] > average_score THEN
APPEND studentidentifier[i] TO aboveaverage_students
ENDIF
END FOR
OUTPUT averagescore, aboveaverage_students
END