# Division of Complex Numbers in C++

Division of complex numbers in c++. This page provides c++ program for division of complex numbers.

A complex number is type of number in number system that has two parts viz. real numbers and imaginary number.

A complex number is represented in the form of a + bi where a and b are real numbers and i is imaginary number.

This program is entirely similar to addition of complex numbers in c++. So if you want to check the explanation of this program you can check that article.

## Division of Complex Numbers in C++

Here is the source code of C++ program to add, subtract, multiply and divide two complex numbers
```/* Aim: Write a C++ program to divide two complex numbers */

#include<iostream>
using namespace std;

class complex
{
float a,b;

public:
complex()
{
a=b=1;
}

complex(float x, float y)
{
a=x;b=y;
}

complex operator / (complex c2)
{
complex tmp;

tmp.a=(a*c2.a+b*c2.b)+(c2.a*b-a*c2.b);
tmp.b=(c2.a*c2.a)+(c2.b*c2.b);

return tmp;
}

void display()
{
if(b>=0)
cout<<" Complex number : "<<a<<"+"<<b<<"i"<<endl;
else
cout<<" Complex number : "<<a<<b<<"i"<<endl;
}

void display(char op)
{
cout<<a<<"i"<<"/"<<b<<endl;
}

};

int main()
{
complex c1(7,-3),c2,c3;

c1.display();
c2.display();

cout<<" Division is ";

c3=c1/c2;

c3.display('d');

return 0;
}

/* Output of above code:-

Complex number : 7-3i
Complex number : 1+1i

Division is -6i/2

*/
```

### Related articles to division of complex numbers in c++

You might want to check same program with multiplication operator, multiplication of complex numbers in c++.