Question: write the int main for the below code in c++ and display it class complex { double real; double imaginary; public: complex() { real =

write the int main for the below code in c++ and display it

class complex

{

double real;

double imaginary;

public:

complex()

{

real = 0;

imaginary = 0;

}

void set_complex(double r,double i)

{

real =r;

imaginary =i;

}

double get_real()

{

return (real);

}

double

get_imaginary()

{

return

(imaginary);

}

char sign(double z)

{

return

((z< 0) ?'-':'+');

}

void display_complex()

{

if

(imaginary == 0)

cout <

else if

(real == 0 && imaginary != 0)

cout << sign(imaginary) << "i"<

else

cout<

}

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!