Docsity

Sentinel-Controlled Repetition: Class Average Program, Exercises of Programming for Engineers

Toggle sidebar
bg1
Lab Work
(Programming-ll-EE112)
Formulating Algorithms: Sentinel-Controlled Repetition
Develop a class average program that processes grades for an arbitrary number of
students each time it is run. Also draw the Flow chart for this problem.
Class average problem pseudocode algorithm with sentinel-controlled repetition
1 Initialize total to zero
2 Initialize counter to zero
3
4 Prompt the user to enter the first grade
5 Input the first grade (possibly the sentinel)
6
7 While the user has not yet entered the sentinel
8 Add this grade into the running total
9 Add one to the grade counter
10 Prompt the user to enter the next grade
11 Input the next grade (possibly the sentinel)
12
13 If the counter is not equal to zero
14 Set the average to the total divided by the counter
15 Print the total of the grades for all students in the class
16 Print the class average
17 else
18 Print "No grades were entered"
docsity.com

Partial preview of the text

Download Sentinel-Controlled Repetition: Class Average Program and more Exercises Programming for Engineers in PDF only on Docsity!

Lab Work

(Programming-ll-EE112)

Formulating Algorithms: Sentinel-Controlled Repetition

Develop a class average program that processes grades for an arbitrary number of students each time it is run. Also draw the Flow chart for this problem.

Class average problem pseudocode algorithm with sentinel-controlled repetition

1 Initialize total to zero 2 Initialize counter to zero 3 4 Prompt the user to enter the first grade 5 Input the first grade (possibly the sentinel) 6 7 While the user has not yet entered the sentinel 8 Add this grade into the running total 9 Add one to the grade counter 10 Prompt the user to enter the next grade 11 Input the next grade (possibly the sentinel) 12 13 If the counter is not equal to zero 14 Set the average to the total divided by the counter 15 Print the total of the grades for all students in the class 16 Print the class average 17 else 18 Print "No grades were entered"

docsity.com