Iteration

Additional Exercises


  1. In the train time table program, add loops to check that the times entered are valid (ie times entered are between 0 and 24 hours for the start and stop times and that the frequency and journey times are between 1 and 60 minutes).

    Prevent the program from proceeding until suitable values are entered.

  2. Write a program which reads in a set of positive value real number values terminated by a negative value and prints out the sum of all these values.

  3. Write a program to find the largest, smallest and average values in a collection of n numbers entered by the user where n is the first data item entered.


Back to Main Page for Lecture 4