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

#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


Please Help Members By Posting Answers For Below Questions

types of highways

1444


how to works epbx? how to configuration the epbx?

1937


What are the most asked questions for learner operators in the interview for eskom?

2006


what is the difference between interface and abstract class

2193


c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.

2175


Book for preparation of HPCL (CS/IT) .

2682


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.

6755


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

2364


what is monetary policy

2372


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

2348


Why voltage drops in star connected motor And how IL=ph

1716


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

1749


sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers

2249


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

2433


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

3414