CS13002 Programming and Data Structures

Section: 5/E, Spring 2006

Warm-up assignment
(Not for submission)

Part I

Find out at what times between 10 and 11 hours, the hour and minute hands of a clock are perfectly perpendicular to one another. Print the times as

     10 hours m minutes,

where m is a floating-point number larger than or equal to 0 and less than 60.

Part II

Try to generalize the above program. The user inputs an hour h between 1 and 12. Your task is to find out at what times of the form

     h hours m minutes

the hour and minute hands of a clock are perfectly perpendicular to one another. Here 0 <= m < 60. Exactly two of the twelve possible values of h correspond to single solutions for m. Locate these values of h.

Notice that for solving this part, you may have to use a conditional statement (an if statement). If you do not know how such statements can be written, repeat Part I with 10 hours replaced by 6 hours and also by 2 hours.


Course home