I run a program for complex numbers in C .There are various type of complex number keyword declared in
#include <complex> .Here are some:-
1)_complex //takes double
2)_C_double_complex //takes double
#include <complex> .Here are some:-
1)_complex //takes double
2)_C_double_complex //takes double
3)_C_float_complex //takes float
4)_C_ldouble_complex //takes long double
I have used them in my program and perform various operation like addition ,substraction,multiplication and division.Here is the program and output:-
#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<msclr/safebool.h>
#include<complex>
void main()
{
bool a=false; //C++
//printf("boola=",a);
_complex c={12.66,34.787};
_complex d={1,34};
_complex e={(c.x+d.x),(c.y+d.y)};
printf("%lf\t%lf\n",e.x , e.y);
_C_double_complex a={12.34,65.7};
_C_double_complex b={2.34,65.7};
_C_double_complex g={a._Val[0]-b._Val[0],a._Val[1]-b._Val[1]};
printf("%lf\t%lf\n",g._Val[0] , g._Val[1]);
_C_ldouble_complex f={234.79345,12.64233};
_C_ldouble_complex h={1,2};
_C_ldouble_complex i={f._Val[0]*h._Val[0],f._Val[1]*h._Val[1]};
printf("%Lf\t%Lf\n",i._Val[0] , i._Val[1]);
_C_float_complex j={11.89,2.001};
_C_float_complex k={1,2.001};
_C_float_complex l={j._Val[0]/k._Val[0],j._Val[1]/k._Val[1]};
printf("%f\t%f\n",l._Val[0] , l._Val[1]);
_getch();
}
Output:-
13.660000 68.787000
10.000000 0.000000
234.793450 25.284660
11.890000 1.000000
*Here we use an another variable bool which takes two values true and false.It is declared in header #include<msclr/safebool.h> .
No comments:
Post a Comment