Test 1: Class Section D

Test 1: Class Section D

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. Given two complex numbers of the form:

and

where:

then the product of these two complex numbers is defined by:

where:

and:

Your program should get values for the real and imaginary parts of two complex numbers and (i.e. get the components , , and above), and print out the product (i.e. the components and ).

Your program must do the following:



McMullin@ugmail.eeng.dcu.ie
Wed Jan 10 10:46:37 GMT 1996