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
richman keeps in pocket poor man throws and kids eat me am an english word P-U--E--L
Sir Pl Provide the diploma nautical science sample paper
WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
Respected sir/madam, My self R SANKAR. I am final year BE civil engineering student (2014-2018). i have shortlisted for isro exam 2018.last university exam (7th sem) result was declared i have scored 6.98CGPA. but they not provide last result mark sheet still now 1. What are the documents bring to isro exam venue? 2. either bring bonafide certificate from college instead of mark sheets?
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?
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?
could u send me the model papers for drug inspector exam at imrupinder@gmail.com
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
in vfd why we did not give directac ac supply?
weather any body knows how th partiton of sections in rrb is aote 1,genera nowlge 2,intellgince 3,maths 4,english 5,science
the servents of india society was founded by ?
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 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.