## Pages

### Complex numbers program in c language | CTechnotips

Complex numbers definition

Complex numbers are two dimensional numbers i.e. it consists real part and imaginary part.
Complex numbers are written as a + ib
Where a and b are real numbers and i2 = -1

Code 1:
1. How to use complex numbers in c
2. C language complex numbers
#include<stdio.h>
int main(){
int a,b;
printf("Enter any complex number in the format a+ib: ");
scanf("%d+i%d",&a,&b);
printf("Real part is: %d",a );
printf("\nImaginary part is: %d",b);
return 0;
}

Code 2:
1. C program to printf complex numbers

#include<stdio.h>
int main(){
int a,b;
printf("Enter the real part of complex number: ");
scanf("%d",&a);
printf("Enter the imaginary part of complex number: ");
scanf("%d",&b);
printf("\nComplex number is: %d%+di",a,b );
return 0;
}

Operation on complex numbers:

Addition of complex number
(a + ib) + (c + id) = (a+c) + i(b+d)
Subtraction of complex numbers
(a + ib) -(c + id) = (a+c) + i(b-d)
Multiplication of complex numbers
(a + ib) *(c + id) = (ac-bd) + i(bc+ad)
Divison of complex numbers
(a + ib) / c + id) = ((ac + bd) + i(bc-ad))/(c2 + d2)