# Question Solved1 AnswerMake a C program “ccalc.c” which takes 4 double arguments (x1, x2, y1 and y2). It outputs the calculation result c1 + c2, c1 - c2, c1 * c2, c1 / c2, where c1 = (x1 + y1 i) and c2 = (x2 + y2 i); NOTE: You should declare a struct named ComplexNumber. Then you should define functions, cadd, csub, cmul and cdiv. The arguments of these functions must be ComplexNumber type. You must be able to get the outputs below.  Reference: #include <stdio.h> // Define CompleNumber struct // cadd struct ComplexNumber cadd(struct ComplexNumber c1, struct ComplexNumber c2) { } // csub // cmul // cdiv // Define necessary functions here... void printFormula(char* operator, struct ComplexNumber c1, struct ComplexNumber c2, struct ComplexNumber result) {     printComplexNumber(c1);     printf(" %s ", operator);     printComplexNumber(c2);     printf(" = ");     printComplexNumber(result);     printf("\n"); } int main(int argc, char** argv) {     struct ComplexNumber c1 = readComplexNumber();        struct ComplexNumber c2 = readComplexNumber();        // Add     struct ComplexNumber ca = cadd(c1, c2);     printFormula("+", c1, c2, ca);     // Subtraction     // Multiplication     // Division     return 0; } $$\$$ gcc ccalc.c $$\ . / a .0 u \mathrm{t}$$ $$5.0-6.0$$ $$3.02 .0$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(8.00+-4.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})-(3.00+2.00 \mathrm{i})=(2.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(27.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i}) /(3.00+2.00 \mathrm{i})=(0.23+-2.15 \mathrm{i})$$

Q3TKTI The Asker · Computer Science

Make a C program “ccalc.c” which takes 4 double arguments (x1, x2, y1 and y2). It outputs the calculation result c1 + c2, c1 - c2, c1 * c2, c1 / c2, where c1 = (x1 + y1 i) and c2 = (x2 + y2 i);

NOTE: You should declare a struct named ComplexNumber. Then you should define functions, cadd, csub, cmul and cdiv. The arguments of these functions must be ComplexNumber type. You must be able to get the outputs below.

Reference:

#include <stdio.h>

// Define CompleNumber struct

struct ComplexNumber cadd(struct ComplexNumber c1, struct ComplexNumber c2)
{
}

// csub

// cmul

// cdiv

// Define necessary functions here...

void printFormula(char* operator, struct ComplexNumber c1, struct ComplexNumber c2, struct ComplexNumber result)
{
printComplexNumber(c1);
printf(" %s ", operator);
printComplexNumber(c2);
printf(" = ");
printComplexNumber(result);
printf("\n");
}

int main(int argc, char** argv)
{

struct ComplexNumber ca = cadd(c1, c2);
printFormula("+", c1, c2, ca);

// Subtraction

// Multiplication

// Division

return 0;
}

Transcribed Image Text: $$\$$ gcc ccalc.c $$\ . / a .0 u \mathrm{t}$$ $$5.0-6.0$$ $$3.02 .0$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(8.00+-4.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})-(3.00+2.00 \mathrm{i})=(2.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(27.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i}) /(3.00+2.00 \mathrm{i})=(0.23+-2.15 \mathrm{i})$$
More
Transcribed Image Text: $$\$$ gcc ccalc.c $$\ . / a .0 u \mathrm{t}$$ $$5.0-6.0$$ $$3.02 .0$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(8.00+-4.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})-(3.00+2.00 \mathrm{i})=(2.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i})+(3.00+2.00 \mathrm{i})=(27.00+-8.00 \mathrm{i})$$ $$(5.00+-6.00 \mathrm{i}) /(3.00+2.00 \mathrm{i})=(0.23+-2.15 \mathrm{i})$$