#include<stdio.h>
struct
complex
{
float
real;
float
imag;
}
c,c1,c2;
void
main()
{
clrscr();
printf("Enter
real and imaginary parts for first number \n");
scanf("%f
%f",&c1.real,&c1.imag);
printf("Enter
real and imaginary parts for second number \n");
scanf("%f
%f",&c2.real,&c2.imag);
printf("Addition
of two complex numbers is..\n");
c.real=c1.real+c2.real;
c.imag=c1.imag+c2.imag;
printf("%f
+ i(%f)\n",c.real,c.imag);
printf("Subtraction
of two complex numbers is..\n");
c.real=c1.real-c2.real;
c.imag=c1.imag-c2.imag;
printf("%f
+ i(%f)\n",c.real,c.imag);
printf("M..\n");
c.real=(c1.real*c2.real)-(c1.imag*c2.imag);
c.imag=(c1.real*c2.imag)+(c1.imag*c2.real);
printf("%f
+ i(%f)\n",c.real,c.imag);
getch();
}
No comments:
Post a Comment