CS209 lab4


http://www.maths.nuigalway.ie/~gettrick/teach/cs209/l4.html




http://www.maths.nuigalway.ie/~gettrick/teach/cs209/progs/
This lab is based on using structures in C to represent and manipulate complex numbers. Write a program in C that reads in from the user four (4) real numbers, x1, y1, x2, y2, that represent the complex numbers z1 = x1 +iy1 and z2 = x2 +iy2. Represent the complex numbers in your program as a structure

typedef struct
        {
                float x;
                float y;
        } comp;
Write functions in your program to
  1. add two complex numbers
  2. multiply two complex numbers
  3. divide the first complex number by the second (Hint: to divide the complex number a+ib by c+id, we simply multiply above and below by c-id to get [(a+ib)(c-id)]/[(c+id)(c-id)].....)
  4. determine which complex number has larger modulus (the value of x2 + y2).
and print out these results to the screen. You must use structures, and you must use a separate function for each calculation.
© NUI, Galway