
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program to Perform Complex Number Multiplication
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 −
Example
#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; }
Output
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 ";
- Related Articles
- Complex Number Multiplication in C++
- C++ Program to Perform Matrix Multiplication
- C++ Program to convert a number into a complex number
- Haskell Program to convert a number into a complex number
- C++ Program to Subtract Complex Number using Operator Overloading
- Python program to define class for complex number objects
- Swift Program to initialize and print a complex number
- Haskell Program to initialize and print a complex number
- C++ Program to initialize and print a complex number
- Python program to convert complex number to polar coordinate values
- Java program to print a multiplication table for any number
- Perform complex MySQL insert by using CONCAT()?
- How to perform element-wise multiplication on tensors in PyTorch?
- Golang Program to Print the Multiplication Table of a Given Number
- Golang Program to get the real part from a Complex number

Advertisements