c++ program to add 2 complex number using operator
overloading technique
Answer Posted / a.bharathi raja bsc.,hdca.,
A.BHA RAJA
THENNAGALAPURI
#include<iostream.h>
#include<conio.h>
class complex
{
int r,i;
public:
{
void getdata(int a,int b)
{
r=a; i=b;
}
complex operator+(complex,complex);
void display(void);
};
complex complex :: operator+(complex a,complex b)
{
complex c;
c.r=a.r+b.r;
c.i=a.i+b.i;
return c;
}
void complex :: display(void)
{
cout<<r<<"+i"<<i<<"\n";
}
void main()
{
complex p,q,r;
int n,m;
clrscr();
cout<<"Enter the real number:";
cin>>n;
cout<<"Enter the imag number:";
cin>>m;
p.getdata(n,m);
cout<<"Enter the real number:";
cin>>n;
cout<<"Enter the imag number:";
cin>>m;
q.getdata(n,m);
r=p+q;
p.display(p);
q.display(q);
r.display(r);
getch();
}
Is This Answer Correct ? | 30 Yes | 12 No |
Post New Answer View All Answers
used of viscocity in petrolium
Why voltage drops in star connected motor And how IL=ph
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
in vfd why we did not give directac ac supply?
Book for preparation of HPCL (CS/IT) .
how to resize the components?
the servents of india society was founded by ?
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
types of highways
What is the number which when divided by 12,15 and 24 gives remainder 5?
richman keeps in pocket poor man throws and kids eat me am an english word P-U--E--L
plz send me bhel paper....
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
could u send me the model papers for drug inspector exam at imrupinder@gmail.com