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
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
.students decide to gift principal 4200 rupees. if teachers give 50% more than the students and an external person gives 3 times to that of teachers.how much do teachers give.
plz send me bhel paper....
What is the differents between the Physics & technical Physics
Can some1 please mail me the question papers of iiit hyderabad...my mail id is cenablogspot@gmail.com
sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers
types of highways
please i need nautical science past question and answer
Sir Pl Provide the diploma nautical science sample paper
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.
what will the output of this program. sint a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a)
Discussion Topic: “Statutory Defintions” Discussion Questions: Q1 Is it correct that a loan or an advance by a private limited company to a shareholder of the company is considered as payment of dividend? Explain your views. Q2 Will a loan or advance by a private limited company to its holding company be considered as payment of dividend if the subsidiary possesses sufficient amount of accumulated profits?
what is monetary policy
can i have the model papers for gate along with answers on my email id krish231191@gmail.com please???
please send me NTPC previous papers on my email ID 18amarjeet.civil@gmail.com or mr.yadav143@gmail.com