Test 2: Class Section C
Test 2: Class Section C
Friday 12th May 1995
This test will be made up of three parts:
- Debugging, running and testing a provided program.
- Making use of the above program in the development of a new
program and then testing this extensively.
- Making minor alterations to the original program in order to
improve the quality of the code, and/or to add additional
functionality.
Note that marks will be awarded purely on the quality of the content of
the final report. Therefore, at all stages of the test, please describe
plans, algorithms, problems encountered, tests carried out and, when the
required tasks have been completed, describe any conclusions drawn from
the exercise.
The program POLARMUL.C in supposed to
take in the rectangular co-ordinates of two complex numbers, convert
them to polar and multiply them. The product is then printed to the
screen in polar co-ordinates. There are, however, a number of errors in
the program.
- (a) Present a reformatted version of this program which
demonstrates satisfactory practice for spacing, line
breaking and indentation. Add comments where relevant to
improve the understandability of the program.
- (b) Correct any compiler / linker errors. In the case of
compiler warnings, either resolve them or explain why
they can be ignored.
- (c) When the program compiles successfully, run it and
establish the presence of any runtime errors. Correct
these.
- (d) Test the program extensively to ensure correct
operation.
Refine the POLARMUL.C program by adding
the following functionality:
- The only variables which may be globally defined are modulus
and theta - the values of all other variables should be passed
between functions using parameters and/or return values as
appropriate.
- Write a function which converts the final solution back into
rectangular co-ordinates, according to the formula:

The product should now be printed to the
screen in both polar and rectangular co-ordinates.
The following guidelines must be followed:
- The program must remain divided into functions.
- The program should demonstrate good coding practices with regard
to spacing, comments etc.
- Test this program rigorously and
detail all results.
- polarmul.c currently prints the argument of the solution in
radians. Develop a function which converts this radian value to degrees
and incorporate it into the program.
- polarmul.c should not be restricted to multiplying two
complex numbers only - alter it so that the user is initially prompted
for the number of complex numbers to be entered and then that number are
read in and multiplied, yielding a single product which is printed out.
McMullin@ugmail.eeng.dcu.ie
Fri May 12 08:46:32 BST 1995