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 / sundari.b.v

#include<iostream.h>
#include<conio.h>
class complex
{
float x;
float y;
public:
complex(){}
complex(float real,float imag)
{
x=real;
y=imag;
}
complex operator+(complex);
void display(void);
};
complex complex::operator+(complex c)
{
complex temp;
temp x=x+c.x;
temp y=x+c.y;
return
}
void complex::display(void)
{
cout<<x<<"+j"<<y<<"\n";
}
int main()
{
complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"c1=",c1.display();
cout<<"c2=",c2.display();
cout<<"c3=",c3.display();
return 0;
}

Is This Answer Correct ?    23 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to resize the components?

2281


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

1697


what is theaverage weight of one brick?

2264


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

2158


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

1871


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

2337


in which state of india has no panchayatraj

1803


why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments

2050


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

1477


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

1731


why does find out power factor?

1845


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

1991


If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?

2879


the servents of india society was founded by ?

2069


Sir Pl Provide the diploma nautical science sample paper

2454