c++ program to add 2 complex number using operator
overloading technique
Answer Posted / a.bharathi raja
#include<iostream.h>
#include<conio.h>
class complex
{
int r;
int i;
public:
complex()
{ }
complex(int a,int b)
{
r=a;i=b;
}
friend complex operator+(complex,complex);
friend show(complex);
complex operator+(complex c1,complex c2)
{
complex c3;
c3.r=c1.r+c2.r;
c3.i=c1.i+c2.i;
return(c3);
}
show(complex c)
{
cout<<c.r<<"i+"<<c.i<<endl;
}
void main()
{
complex a,b,c;
clrscr();
a.complex(3,6);
b.complex(4,7);
c=a+b;
show(a);
show(b);
show(c);
getch()
}
| Is This Answer Correct ? | 24 Yes | 11 No |
Post New Answer View All Answers
What are the most asked questions for learner operators in the interview for eskom?
The horse has played a little known but very important role in the field of medicine. Horses were injected with toxins of diseases until their blood built up immunities. Then a serum was made from their blood.Serums to fight with diphtheria and tetanus were developed this way. It can be inferred from the passage, that horses were (A) given immunity to diseases (B) generally quite immune to diseases (C) given medicines to fight toxins (D) given diphtheria and tetanus serums
weather any body knows how th partiton of sections in rrb is aote 1,genera nowlge 2,intellgince 3,maths 4,english 5,science
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
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?
used of viscocity in petrolium
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.
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
I am looking for bank exam coaching in Hyderabad. Can anybody tell me which is the best institute for BANK and which branch is good giving me branch details.
REPO Structure and terminology
i have M.TECH interview on RF AND MICROWAVE ENGINEERING IN IIT (KHARAGPUR/ROORKEE).KINDELY TELL WHAT SUBJECTS SHOULD I READ AND WHAT ARE THE INTERVIEW QUESTIONS.
in vfd why we did not give directac ac supply?
please i need nautical science past question and answer
plz send me bhel paper....