answersLogoWhite

0


Best Answer

/*C++ program to multiply two complex numbers using * operator overloading*/

#include<iostream.h>

#include<conio.h>

class complex

{

float x,y;

public:

complex() {}

complex(float real,float img)

{

x=real; y=img;

}

complex operator*(complex);

void display()

{

cout<<x<<" + "<<y<<"i"<<endl;

}

};

complex complex::operator*(complex e)

{

complex temp;

temp.x=x*e.x+y*e.y*(-1);

temp.y=x*e.y+y*e.x;

return(temp);

}

void main()

{

clrscr();

complex c1(5,3),c2(3,2),c3=c1*c2;

c1.display();

c2.display();

cout<<"Multiplication"<<endl;

c3.display();

getch();

}

OUTPUT:

5 + 3i

3 + 2i

Multiplication

9 + 19i

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to multiply two complex no?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to display multiplication of two matrix?

The matrix multiplication in c language : c program is used to multiply matrices with two dimensional array. This program multiplies two matrices which will be entered by the user.


Is there a c program to multiply two polynomials using linked lists?

yes


Write a program in C language to multiply any two numbers without using in source code?

The question is malformed and incomprehensible.


Write a program to write the sum of two complex number using friend function and overloading constractor?

#include&lt;iostream.h&gt; #include&lt;conio.h&gt; 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&lt;&lt;c.r&lt;&lt;"i+"&lt;&lt;c.i&lt;&lt;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() }


How do multiply similar fraction?

To multiply two fractions, whether or not they are similar, the numerator of the answer is the product of the two numerators. The denominator of the answer is the product of the two denominators.So (a/b)*(c/d) = (a*c)/(b*d).


Write a c program on blood bank automation system?

Not possible to write one here (too complex). Look for a commercial program to do this.


What is difference of complex numbers?

If y = a + bi and z = c + di are two complex numbers then z - y = (c - a) + (d - b)i


What is algorithm to multiply two matrices?

a,b,c,d,


How do you multiply a number containing a complex number?

One way, use binomial multiplication. Example: (w + x)*(y + z) = {using the FOIL method} w*y + w*z + x*y + x*z, so if we have two complex numbers multiplied:(a + b*i)*(c + d*i) = a*c + a*d*i + b*c*i + b*d*i*i, but i*i = -1, so this becomes:(a*c - b*d) + (a*d + b*c)*iAnother way to express complex numbers is as a magnitude and an angle. If this is the case, then you multiply the two magnitudes, and add the angles, then reduce the resultant angle to within -180&Acirc;&deg; and +180&Acirc;&deg;.If you have a real X complex, then just use {b=0} in (a + b*i), so then you have:(a*c) + (a*d)*i *Or if using the polar coordinates, take the angle as 0&Acirc;&deg; for a positive real number and 180&Acirc;&deg; for a negative real number, then add the angles.


How can you divide a fraction by a fraction using multiplication?

You find the reciprocal of the second fraction- flip it over. And then you multiply the two fractions.So (a/b) / (c/d) = (a/b) * (d/c)You find the reciprocal of the second fraction- flip it over. And then you multiply the two fractions.So (a/b) / (c/d) = (a/b) * (d/c)You find the reciprocal of the second fraction- flip it over. And then you multiply the two fractions.So (a/b) / (c/d) = (a/b) * (d/c)You find the reciprocal of the second fraction- flip it over. And then you multiply the two fractions.So (a/b) / (c/d) = (a/b) * (d/c)


How do write a program in c plus plus for addition and subtraction of two complex numbers?

#include&lt;iostream&gt;#include&lt;complex&gt; int main () { using namespace std; complex a {1, 1}; complex b {42, 2}; cout a &lt;&lt; " + " &lt;&lt; b &lt;&lt; " = " &lt;&lt; a + b &lt;&lt; endl; cout a &lt;&lt; " - " &lt;&lt; b &lt;&lt; " = " &lt;&lt; a - b &lt;&lt; endl; }


How to calculate the division of complex number?

for two numbers: a + bi and c + di in rectangular format: (a + bi)/(c + di) can be calculated as follows: Multiply numerator and denominator by complex conjugate of the denominator: ( c - di). This gives (ac - bd + bci - bdi) / (c2 + d2). Now the denominator is a real number. If you have them in polar form: Magnitude&lt;Angle. Then divide the magnitudes and subtract the angles.