answersLogoWhite

0

/*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

14y ago

What else can I help you with?

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.


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.


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() }


What is algorithm to multiply two matrices?

a,b,c,d,


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


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 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.


C program for comparison of two words?

strcmp


How to multiply two int pointer variable in C language?

You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *