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
how to prepare for bcil bitp
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.
please i need nautical science past question and answer
why the uncontrolled rectifiers are converting fixed ac to fixed dc only why not it is converting variable dc
richman keeps in pocket poor man throws and kids eat me am an english word P-U--E--L
sir can you send me previous question paper of jsplGET entrance test
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?
Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is
Sir Pl Provide the diploma nautical science sample paper
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
how to works epbx? how to configuration the epbx?
What is the number which when divided by 12,15 and 24 gives remainder 5?
what will the output of this program. sint a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a)
I have cleared sbi clerk and have interview in 26/04/2010.But I am M.Ed & B.Ed,i want to u know my answed about not chose the teaching post
plz send me bhel paper....