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
what will the output of this program. sint a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a)
how to works epbx? how to configuration the epbx?
Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is
plz send me bhel paper....
used of viscocity in petrolium
the servents of india society was founded by ?
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers
what is monetary policy
Design the test cases for Boundary Value analysis of the following. Consider a program that prompts the user to input three numbers (say x, y, z) and the data type for input parameters ensures that these will be integers greater than 0 and less than or equal to 100. The program should then output the numbers in ascending order.
What is the differents between the Physics & technical Physics
types of highways
why does find out power factor?
in vfd why we did not give directac ac supply?
how to resize the components?
why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments