Subtraction of two complex number in C by R4R Team

Complex number:

Example :
2+3i
0+4i
-1-9i
These kind of number are known as complex number.
where 'i' is root -1.

Syntax-
a+bi
where,
'a' is the real part of the complex number
'b' is the imaginary part of the complex number.

Subtraction of complex number:
x=3+4i
y=1+i
then x-y=2+3i


program-

#include< stdio.h>
#include< string.h>
int main() {
int r1,i1,r2,i2;
printf("Enter real and imaginary part of first complex number\n");
scanf("%d%d",&r1,&i1);
printf("Enter real and imaginary part of second complex number\n");
scanf("%d%d",&r2,&i2);
printf("Subtraction of second complex number by first complex number is %d+%di",r1-r2,i1-i2);
}


output-

Enter real and imaginary part of first complex number
3
4
Enter real and imaginary part of second complex number
1
2
Subtraction of second complex number by first complex number is 2+2i

-In this program, we take an input of real and imaginary part of the two complex number.
-Subtract real part to real part, and subtract imaginary part to imaginary part, then display both things.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!