1
#include<stdio.h>
typedef struct ComplexType
{
float realPart,imagePart;
} ComplexType;
ComplexType add(ComplexType z1, ComplexType z2);
ComplexType sub(ComplexType z1, ComplexType z2);
ComplexType multiply(ComplexType z1, ComplexType z2);
int main()
{
ComplexType a,b,c1,c2,c3;
scanf("%f %f",&a.realPart,&a.imagePart);
scanf("%f %f",&b.realPart,&b.imagePart);
c1=add(a,b);
printf("%f+%fi",c1.realPart,c1.imagePart);
c2=sub(a,b);
printf("%f+%fi",c2.realPart,c2.imagePart);
c3=multiply(a,b);
printf("%f+%fi",c3.realPart,c3.imagePart);
return 0;
}
ComplexType add(ComplexType z1, ComplexType z2){
ComplexType temp;
temp.realPart=z1.realPart+z2.realPart;
temp.imagePart=z1.imagePart+z2.imagePart;
return temp;
}
ComplexType sub(ComplexType z1, ComplexType z2){
ComplexType temp;
temp.realPart=z1.realPart-z2.realPart;
temp.imagePart=z1.imagePart-z2.imagePart;
return temp;
}
ComplexType multiply(ComplexType z1, ComplexType z2){
ComplexType temp;
temp.realPart=z1.realPart*z2.realPart;
temp.imagePart=z1.imagePart*z2.imagePart;
return temp;
}