# How to write a c program to find addition and subtraction of two complex numbers

Complex number: A complex number is a number that can be put in the form a + bi, where a and b are real numbers and i is called the imaginary unit, In a + ib, a is called the real part and b the imaginary part of the complex number.

1>Write a c program to find addition and subtraction of complex numbers or add, subtract two complex numbers or print addition and subtraction of complex numbers or show addition and subtraction of complex numbers

//Write a c program to find addition and subtraction of complex numbers or add, subtract two complex numbers or print addition and subtraction of complex numbers or show addition and subtraction of complex numbers

#include<stdio.h>

int main(){

int a,b,c,d,x,y;

printf(“\nTo add subtract two complex numbers \n:”);

printf(“\nEnter the first complex number a & b values:”);

scanf(“%d%d”,&a,&b);

printf(“\nEnter the second complex number a & b values:”);

scanf(“%d%d”,&c,&d);

if(b<0)

printf(“%d-i\n”,a-b);

else

printf(“d+i\n”,a+b);

if(d<0)

printf(“d-i\n”,c-d);

else

printf(“%d+i\n”,c+d);

printf(“\nADDITION OF TWO COMPLEX NUMBERS IS”);

x=a+c;

y=b+d;

if(y>0)

printf(“%d-i%d”,x,-y);

else

printf(“%d+i%d”,x,+y);

printf(“\n\nSUBTRACTION OF TWO COMPLEX NUMBERS IS “);

x=a-c;

y=b-d;

if(y<0)

printf(“%d-i%d”,x,-y);

else

printf(“%d+i%d”,x,+y);

return 0;

}

output:

To add subtract two complex numbers

Enter the first complex number a & b values:

4 5

Enter the second complex number a & b values:

2 3

ADDITION OF TWO COMPLEX NUMBERS IS 6 + 8i

SUBTRACTION OF TWO COMPLEX NUMBERS IS 2 + 2i