Test 1: Class Section B

Test 1: Class Section B

Spring 1995

The exercise consists of two parts. Marks will be divided equally between the two parts. The report should have separate Plan, Coding and Testing sections for the two parts; there should be a single Conclusion section.

The two parts are independent (i.e. you do not have to complete the first in order to attempt the second, or vice versa). Therefore, it is recommended that you plan your allocation of time between the two parts carefully in advance, and stick to this allocation during the test.

Part 1: Analysis

Consider the file TRIANG.C.

This is supposed to be a C program to calculate the area of a triangle. It should request measurements of the relevant dimensions of the triangle, to be input from the keyboard, calculate the area, and display the result on the screen.

The program has various deficiencies. You are required to correct all deficiencies you can identify. For all changes that you make, the report should contain a clear statement of the change and a specific explanation of your rationale for the change. Of course, if you are making several similar or related changes, you may discuss these as a unit.

When you have reached the point where you think the program should work, then you should test it, and report on these tests. Carry out, and report on, further corrections if necessary.

Part 2: Synthesis

You are required to develop (code, test, debug) a C program to carry out the following calculation.

There are 60 seconds in a minute, and 60 minutes in an hour. Write a program which will take an (integral) number of seconds (in the range from 0 up to 100000) and express this in terms of hours, minutes and seconds.

The essential idea of the calculation is as follows. To convert from seconds to minutes and seconds, you must divide by 60 in "integer" fashion - i.e. calculating both an (integer) "quotient" and an (integer) "remainder". The quotient is then the number of minutes, and the remainder is the number of additional or remaining seconds. Repeating this for the minutes you can then convert it into hours and minutes.

Your program must do the following:



McMullin@ugmail.eeng.dcu.ie
Wed Jan 10 10:33:50 GMT 1996