Professional Documents
Culture Documents
Omputer Rogramming: Session 3: Loops (Part 2)
Omputer Rogramming: Session 3: Loops (Part 2)
Omputer Rogramming: Session 3: Loops (Part 2)
Iván Amaya
CONTENTS
SENTINEL VALUE
EXERCISES
E.g.: Create a program that reads a set of grades and calculates the average
grade of the course. Consider the grade -1 as a sentinel value.
There are a couple cities (A and B). At the beginning of year 2000, city A
had popA inhabitants whilst city B had 50% more. If each city grows at a
rate ratA and ratB (respectively), create a program that simulates both
growths and report the year in which the population of A becomes higher
than the one of B.
A school offers a vast amount of courses and each one has a varied demand
of students. But, due to institutional policy, all classes are graded
throughout four exams. Thus, the board requires you to build an algorithm
for processing the grades of each student in a single course, calculating the
average grade of each student, as well as the number of students who failed
and the average grade achieved by the whole class.
Note: Student lists are ended by including a student with ID and grades
equal to zero. Also, average student grades should be printed with the ID.
COMPUTER PROGRAMMING – SESSION 3 IVÁN MAURICIO AMAYA CONTRERAS 6
EXERCISES
Number reversal