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
REPO Structure and terminology
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
please send me NTPC previous papers on my email ID 18amarjeet.civil@gmail.com or mr.yadav143@gmail.com
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
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
Respected sir/madam, My self R SANKAR. I am final year BE civil engineering student (2014-2018). i have shortlisted for isro exam 2018.last university exam (7th sem) result was declared i have scored 6.98CGPA. but they not provide last result mark sheet still now 1. What are the documents bring to isro exam venue? 2. either bring bonafide certificate from college instead of mark sheets?
Book for preparation of HPCL (CS/IT) .
22. A solution of 1% (w/v) starch at pH 6.7 is digested by 15 μg of β‐amylase (mol wt 152,000). The rate of maltose (mol wt = 342) had a maximal initial velocity of 8.5 mg formed per min. The turnover number is
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers
what is monetary policy
Equivalent resistance of 100 homs and 200 homs resistors connected in parallel is
in which state of india has no panchayatraj