Cpp Code for Complex Number

This cpp programming code is used to find the complex number. You can select the whole cpp code by clicking the select option and can use it. When you click text, the code will be changed to text format. This cpp program code will be opened in a new pop up window once you click pop-up from the right corner. You can just copy, paste this cpp code and use it to find the complex number.

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a1,a2,b1,b2,m1,m2,m3,m4,d,r1,s;
    float r,r2,x,y;
    a1=5; b1=2; a2=7;b2=-4;d=0;s=0;
    //Multiplication of complex number
    m1=a1*a2;
    m2=b1*(-(b2));
    m3=a1*b2;
    m4=a2*b1;
    int m5=(m1+m2);
    int m6=m3+m4;
    if(m6>0)
        cout<<"
Multiplication of complex num: "<<m5<<m6<<"+"<<m5<<m6<<"i";
    else
        cout<<"
Multiplication of complex num: "<<m5<<m6<<" "<<m5<<m6<<"i";
    //Division of complex number
    d=(a2*a2) +(b2*b2);
    if(m6>0)
        cout<<"
Division of complex num:("<<m5<<m6<<"+"<<m5<<m6<<"i)/"<<m5<<m6<<"";
    else
        cout<<"
Division of complex num:("<<m5<<m6<<" "<<m5<<m6<<"i)/"<<m5<<m6<<"";
    //Squareroots of complex number
    r1=(5*5)+(2*2);
    r=sqrt(r1);
    r2=(r-a1)/2;
    y=sqrt(r2);
    x=b1/(2*y);
    cout<<"
Square Root(1): "<<x<<"  +"<<y<<"i";
    cout<<"
Square Root(2):-"<<x<<"  -"<<y<<"i";   
}
Other Programming Codes
Online Calculator : Complex Number
Click on the select code link to copy and paste this free cpp program code for complex number.

english Calculators and Converters


Sitemap