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
how to resize the components?
Why voltage drops in star connected motor And how IL=ph
what is theaverage weight of one brick?
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
why the uncontrolled rectifiers are converting fixed ac to fixed dc only why not it is converting variable dc
I have cleared sbi clerk and have interview in 26/04/2010.But I am M.Ed & B.Ed,i want to u know my answed about not chose the teaching post
in which state of india has no panchayatraj
why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments
What is the number which when divided by 12,15 and 24 gives remainder 5?
Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is
why does find out power factor?
What are the most asked questions for learner operators in the interview for eskom?
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
the servents of india society was founded by ?
Sir Pl Provide the diploma nautical science sample paper