Complex numbers program in c







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)




Alogrithm:








1. Write a c program to convert decimal number to hexadecimal number.
3. Write a c program to convert octal number to decimal number.
4. Write a c program to convert octal number to hexadecimal number.
5. Write a c program to convert hexadecimal number to decimal number.
6. Write a c program to convert hexadecimal number to octal number.
8. Write a c program to convert binary number to hexadecimal number.
9. Write a c program to convert binary number to octal number.
11. Write a c program to convert hexadecimal number to binary number.
12. Write a c program to convert octal number to binary number.
14. Write a c program to convert centigrade to fahrenheit.

No comments: