Search This Blog

Friday, 21 August 2020

add complex number cpp

 #include<iostream>

#include<conio.h>

#include<cmath>

using namespace std;


typedef struct C

{

float R;                //REAL

float I;                //IMAGINARY

}

CN;                              //complexnumber

CN ACN(C,C);           //addcomplexnumbers               COMPLEX

int main()

{

CN n1,n2,TN;                      //TEMPARARY NUMBER

char SOI;                         //signofimaginary

cout<<"\n\t\tFor 1st Complex number , "<<endl;

cout<<"\n\t\tEnter the Real and imaginary part :\n";

cin>>n1.R>>n1.I;

cout<<endl<<"\n\t\tFor 2nd Complex number ,"<<endl;

cout<<"\n\t\tEnter the Real and imaginary part :\n";

cin>>n2.R>>n2.I;

SOI = (TN.I>0)?'+':'-';

TN=ACN(n1,n2);

cout<<"\n\t\tCalcualtion of the real and imginary numbers is :\n\n";

cout<<"\n\t\tsum = "<<TN.R<<TN.I<<"i";

return 0;

}

CN ACN(C n1,C n2)

{

C T;

T.R=n1.R+n2.R;

T.I=n1.I+n2.I;

return (T);

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts