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
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers
Design the test cases for Boundary Value analysis of the following. Consider a program that prompts the user to input three numbers (say x, y, z) and the data type for input parameters ensures that these will be integers greater than 0 and less than or equal to 100. The program should then output the numbers in ascending order.
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
I am looking for bank exam coaching in Hyderabad. Can anybody tell me which is the best institute for BANK and which branch is good giving me branch details.
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
What is the differents between the Physics & technical Physics
could u send me the model papers for drug inspector exam at imrupinder@gmail.com
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?
please send me NTPC previous papers on my email ID 18amarjeet.civil@gmail.com or mr.yadav143@gmail.com
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
what will the output of this program. sint a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a)
the servents of india society was founded by ?
Why voltage drops in star connected motor And how IL=ph
Book for preparation of HPCL (CS/IT) .