Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

how to prepare for bcil bitp

2233


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.

6772


please i need nautical science past question and answer

2856


why the uncontrolled rectifiers are converting fixed ac to fixed dc only why not it is converting variable dc

1903


richman keeps in pocket poor man throws and kids eat me am an english word P-U--E--L

2523


sir can you send me previous question paper of jsplGET entrance test

2373


is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?

1495


Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is

1766


Sir Pl Provide the diploma nautical science sample paper

2494


can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???

2276


how to works epbx? how to configuration the epbx?

1953


What is the number which when divided by 12,15 and 24 gives remainder 5?

1522


what will the output of this program. sint a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a)

1608


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

2359


plz send me bhel paper....

2200