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
Why voltage drops in star connected motor And how IL=ph
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers
What is the number which when divided by 12,15 and 24 gives remainder 5?
sir can you send me previous question paper of jsplGET entrance test
22. A solution of 1% (w/v) starch at pH 6.7 is digested by 15 μg of β‐amylase (mol wt 152,000). The rate of maltose (mol wt = 342) had a maximal initial velocity of 8.5 mg formed per min. The turnover number is
the servents of india society was founded by ?
how to works epbx? how to configuration the epbx?
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
please i need nautical science past question and answer
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
What are the most asked questions for learner operators in the interview for eskom?
can u explain me the way to know the relation between the active as well as the reactive power acting on an electical machine under the under excitation as well as over excitation mode
WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY
why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments
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