Create a C program that adds two complex numbers. The numbers are entered from the keyboard. Your code should use the fo
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Create a C program that adds two complex numbers. The numbers are entered from the keyboard. Your code should use the fo
Create a C program that adds two complex numbers. The numbers are entered from the keyboard. Your code should use the following structure to store complex numbers. typedef struct complex s { float real: float imag; } complex; Your code needs to incorporate one function for the addition and one function for the proper printing of the complex number. The function prototypes are given as follows. complex addComplex (complex zi, complex z2); // z3=z1+z2 returns z3 void printcit omplex (complex z);/* prints a complex number on the screen Sample Output 1 Enter the real and imaginary parts of the first number: 5.5 3.4 Enter the real and imaginary parts of the second number: 8.9 5.9 15.5-3.4) - 8.9-5.9) = (14.4-9.31) Sample Output 2 Enter the red and imaginary parts of the first number: 5.2 3.3 Enter the red and imaginary parts of the second number: 8.9-3.3 15.2-3.3i) + 8.9-3.31) = 14.1 Sample Output 3 Enter the real and imaginary parts of the first number 5.5 34 Enter the real and imaginary parts of the second number 8.9-59 5.5-3.41) + (8.9-5.91) = (14.4-2.5i)