Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started