answersLogoWhite

0


Best Answer

#include<iostream.h> #include<conio.h> class complex { int a,b; public: void read() { cout<<"\n\nEnter the REAL PART : "; cin>>a; cout<<"\n\nEnter the IMAGINARY PART : "; cin>>b; } complex operator +(complex c2) { complex c3; c3.a=a+c2.a; c3.b=b+c2.b; return c3; } complex operator -(complex c2) { complex c3; c3.a=a-c2.a; c3.b=b-c2.b; return c3; } complex operator *(complex c2) { complex c3; c3.a=(a*c2.a)-(b*c2.b); c3.b=(b*c2.a)+(a*c2.b); return c3; } complex operator /(complex c2) { complex c3; c3.a=((a*c2.a)+(b*c2.b))/((c2.a*c2.a)+(c2.b*c2.b)); c3.b=((b*c2.a)-(a*c2.b))/((c2.a*c2.a)+(c2.b*c2.b)); return c3; } void display() { cout<<a<<"+"<<b<<"i"; } }; void main() { complex c1,c2,c3; int choice,cont; do { clrscr(); cout<<"\t\tCOMPLEX NUMBERS\n\n1.ADDITION\n\n2.SUBTRACTION\n\n3.MULTIPLICATION\n\n4.DIVISION"; cout<<"\n\nEnter your choice : "; cin>>choice; if(choice==1choice==2choice==3choice==4) { cout<<"\n\nEnter the First Complex Number"; c1.read(); cout<<"\n\nEnter the Second Complex Number"; c2.read(); } switch(choice) { case 1 : c3=c1+c2; cout<<"\n\nSUM = "; c3.display(); break; case 2 : c3=c1-c2; cout<<"\n\nResult = "; c3.display(); break; case 3 : c3=c1*c2; cout<<"\n\nPRODUCT = "; c3.display(); break; case 4 : c3=c1/c2; cout<<"\n\nQOUTIENT = "; c3.display(); break; default : cout<<"\n\nUndefined Choice"; } cout<<"\n\nDo You Want to Continue?(1-Y,0-N)"; cin>>cont; }while(cont==1); getch(); }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to find sum of two complex numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


Write a Shell program to find the smallest number from a set of numbers?

k


Write a program to find the product of two numbers using Halving and Doubling method?

i need this answer


Write a C program to find the square of two numbers?

Please visit http://talentsealed.blogspot.com/2009/10/to-find-sqaure-of-numbers-using-c.htmlfor the answer.


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.


Write a java program to find sum of even and odd numbers in given array?

for(int i = 1; i &lt; 100; i+=2) { System.out.println(i); }


Write a program in C to find the complex number of a given number?

There is no such thing; you seem to have misunderstood something.Any real number can be regarded as a complex number with zero imaginary part, eg.: 5 = 5+0i


How do you write Square program using vb?

write a vb program to find the magic square


Write a Program in c to find palindrome numbers between any two numbers?

please somebody should help me answer this question..I have a project on it even! It seems almost impossible at the moment.


Write a program to print first 100 alternative prime numbers?

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.