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
plz send me bhel paper....
used of viscocity in petrolium
Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is
how to prepare for bcil bitp
WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
Sir Pl Provide the diploma nautical science sample paper
types of highways
how to works epbx? how to configuration the epbx?
in vfd why we did not give directac ac supply?
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
What is the number which when divided by 12,15 and 24 gives remainder 5?
could u send me the model papers for drug inspector exam at imrupinder@gmail.com
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?