Complex Numbers

 class ComplexNumbers {

    // Complete this class

    private:

    int real;

    int img;

    public:

    ComplexNumbers(int real,int img){

        this->real=real;

        this->img=img;

        

    }

    void print(){

       cout<<real<<" + i"<<img; 

}

    void plus(ComplexNumbers c2){

        this->real=this->real+c2.real;

        this->img=this->img+c2.img;

       // print();

    }

    void multiply(ComplexNumbers c2){

        ComplexNumbers c3(1,1);

        c3.real=(this->real*c2.real)-(this->img*c2.img);

        c3.img=((this->real)*c2.img)+((this->img)*c2.real);

        this->real=c3.real;

        this->img=c3.img;

        

       // print();

    }

    

};

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings