Given C code: #include typedef struct compound { float realNumber; float imaginaryNumber; } compound; compound add(compound n1, compound n2); int main() { compound n1, n2, temp; printf("For the first compound number \n"); printf("Enter the real and imaginary parts: "); scanf("%f %f", &n1.realNumber, &n1.imaginaryNumber); printf("\nFor the second compound number \n"); printf("Enter the real and imaginary parts: "); scanf("%f %f", &n2.realNumber, &n2.imaginaryNumber); temp = add(n1, n2); printf("Sum = %.1f + %.1fi", temp.realNumber, temp.imaginaryNumber); return 0; } compound add(compound n1, compound n2) { compound temp; temp.realNumber = n1.realNumber + n2.realNumber; temp.imaginaryNumber = n1.imaginaryNumber + n2.imaginaryNumber; return (temp); } Task: Please change the C program above to execute complicated numeral multiplication. Hint: (e+fi)(g+hi) = (eg−fh) + (eh+fg)i
Given C code:
#include <stdio.h>
typedef struct compound {
float realNumber;
float imaginaryNumber;
} compound;
compound add(compound n1, compound n2);
int main() {
compound n1, n2, temp;
printf("For the first compound number \n");
printf("Enter the real and imaginary parts: ");
scanf("%f %f", &n1.realNumber, &n1.imaginaryNumber);
printf("\nFor the second compound number \n");
printf("Enter the real and imaginary parts: ");
scanf("%f %f", &n2.realNumber, &n2.imaginaryNumber);
temp = add(n1, n2);
printf("Sum = %.1f + %.1fi", temp.realNumber, temp.imaginaryNumber);
return 0;
}
compound add(compound n1, compound n2) {
compound temp;
temp.realNumber = n1.realNumber + n2.realNumber;
temp.imaginaryNumber = n1.imaginaryNumber + n2.imaginaryNumber;
return (temp);
}
Task: Please change the C program above to execute complicated numeral multiplication.
Hint: (e+fi)(g+hi) = (eg−fh) + (eh+fg)i

I have changed your logic in compound function which was previously returning addition of two complex numbers , to return product of two complex numbers as result, Kindly check that out.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









