Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objective: Write a C program thatwill accept as input two complex numbers(in rec

ID: 3615511 • Letter: O

Question

Objective:

   Write a C program thatwill accept as input two complex numbers(in

   rectangular coordinates)and will compute and display the product ofthe

   numbers.

ProgramRequirements:

   - The program shall include the appropriate.h files for a C program (Not

     the same asC++).

   - The program shall use a struct to create acomplex number type.

   - The program shall use typedef to create analias for the new struct
     type.

   - The program shall use printf and scanf towrite to the screen and read

     from thekeyboard.

   - The program shall have a function thatprompts the user to enter a
     single complex number. (This function willbe called twice.)

   - The program shall pass the two complexnumbers to a function that will

     compute and return the product of thetwo numbers.

   - The function shall use malloc to create thememory for the result of the

    product.

   - The function shall use free to release thememory that was“malloced”.

   - The program driver (i.e., main) shalldisplay the result of the product.

Explanation / Answer

//Hope this will helpyou. #include #include typedef struct comp { double x,y; }Complex; void getInput(Complex *p) { printf("Enter complex number "); printf("Enter x:"); scanf("%lf",&p->x); printf("Enter y:"); scanf("%lf",&p->y); printf("Complex number is %lf +%lfi ",p->x,p->y); } Complex * prod(Complex p1,Complex p2) { Complex *p = (Complex *)malloc(sizeof(Complex)); p->x = p1.x * p2.x - p1.y *p2.y; p->y = p1.x * p2.y + p1.y * p2.x; return p; } int main() { Complex p1,p2,*p; getInput(&p1); getInput(&p2); p = prod(p1,p2); printf(" Product of Complex numbers is :%lf +%lfi ",p->x,p->y); free(p); system("pause"); return 0; }