C Program To Perform Arithmetic Operations on Complex Numbers

#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();
}


Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment