Answer to Question #291646 in C++ for rovinaa

Question #291646

Develop a class called Complex that represents a complex number. An example of a complex number is 5 + 10 i (5 is the real part and 10 is the imaginary part of a complex number). Use public integer values to represent the real and imaginary parts of a complex number. 


1
Expert's answer
2022-01-28T10:33:04-0500
#include <iostream>


class complex
{
    
public:
    int re, im;
    complex() { re = 0; im = 0; }
    complex(int r, int i) { re = r; im = i; }
    void display()
    {
        std::cout<<"Real Number: "<<re<<", imaginary number: "<< im<<std::endl;
    }
    
};
int main()
{
    complex c({5, 10});
    
    c.display();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog