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
Book for preparation of HPCL (CS/IT) .
richman keeps in pocket poor man throws and kids eat me am an english word P-U--E--L
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
please send me NTPC previous papers on my email ID 18amarjeet.civil@gmail.com or mr.yadav143@gmail.com
What is the differents between the Physics & technical Physics
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 difference between interface and abstract class
Sir Pl Provide the diploma nautical science sample paper
please i need nautical science past question and answer
types of highways
What are the most asked questions for learner operators in the interview for eskom?
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
Why voltage drops in star connected motor And how IL=ph
WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers