c++ program to add 2 complex number using operator
overloading technique
Answer Posted / sundari.b.v
#include<iostream.h>
#include<conio.h>
class complex
{
float x;
float y;
public:
complex(){}
complex(float real,float imag)
{
x=real;
y=imag;
}
complex operator+(complex);
void display(void);
};
complex complex::operator+(complex c)
{
complex temp;
temp x=x+c.x;
temp y=x+c.y;
return
}
void complex::display(void)
{
cout<<x<<"+j"<<y<<"\n";
}
int main()
{
complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"c1=",c1.display();
cout<<"c2=",c2.display();
cout<<"c3=",c3.display();
return 0;
}
Is This Answer Correct ? | 23 Yes | 6 No |
Post New Answer View All Answers
WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY
why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
sir can you send me previous question paper of jsplGET entrance test
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
weather any body knows how th partiton of sections in rrb is aote 1,genera nowlge 2,intellgince 3,maths 4,english 5,science
please send me NTPC previous papers on my email ID 18amarjeet.civil@gmail.com or mr.yadav143@gmail.com
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?
types of highways
Book for preparation of HPCL (CS/IT) .
22. A solution of 1% (w/v) starch at pH 6.7 is digested by 15 μg of β‐amylase (mol wt 152,000). The rate of maltose (mol wt = 342) had a maximal initial velocity of 8.5 mg formed per min. The turnover number is
plz send me bhel paper....
REPO Structure and terminology
Discussion Topic: “Statutory Defintions” Discussion Questions: Q1 Is it correct that a loan or an advance by a private limited company to a shareholder of the company is considered as payment of dividend? Explain your views. Q2 Will a loan or advance by a private limited company to its holding company be considered as payment of dividend if the subsidiary possesses sufficient amount of accumulated profits?
What is the differents between the Physics & technical Physics