- Related Questions & Answers
- Complex Number Multiplication in C++
- C++ Program to Perform Matrix Multiplication
- C++ Program to Subtract Complex Number using Operator Overloading
- C++ Program to Generate Multiplication Table
- How to perform Multiplication of Exponents of same base using C#?
- Perform complex MySQL insert by using CONCAT()?
- C++ Program to Implement Russian Peasant Multiplication
- C Program to represent a multiplication table.
- C++ Perform to a 2D FFT Inplace Given a Complex 2D Array
- C++ program to perform unique factorization of a Given Number
- acos() function for complex number in C++?
- asin() function for complex number in C++?
- atan() function for complex number in C++?
- abs() function for complex number in c++ ?
- acosh() function for complex number in C++

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Complex numbers are numbers that are expressed as a+bi where i is an imaginary number and a and b are real numbers. Some examples on complex numbers are −

2+3i 5+9i 4+2i

A program to perform complex number multiplication is as follows −

#include<iostream> using namespace std; int main(){ int x1, y1, x2, y2, x3, y3; cout<<"Enter the first complex number : "<<endl; cin>> x1 >> y1; cout<<"\nEnter second complex number : "<<endl; cin>> x2 >> y2; x3 = x1 * x2 - y1 * y2; y3 = x1 * y2 + y1 * x2; cout<<"The value after multiplication is: "<<x3<<" + "<<y3<<" i "; return 0; }

The output of the above program is as follows

Enter the first complex number : 2 1 Enter second complex number : 3 4 The value after multiplication is: 2 + 11 i

In the above program, the user inputs both the complex numbers. This is given as follows −

cout<<"Enter the first complex number : "<<endl; cin>> x1 >> y1; cout<<"\nEnter second complex number : "<<endl; cin>> x2 >> y2;

The product of the two complex numbers is found by the required formula. This is given as follows −

x3 = x1 * x2 - y1 * y2; y3 = x1 * y2 + y1 * x2;

Finally, the product is displayed. This is given below −

cout<<"The value after multiplication is: "<<x3<<" + "<<y3<<" i ";

Advertisements