yo i got this code right
#include <iostream>
using namespace std;
class Complex
{
double real1, real2, imag1, imag2;
public:
Complex(double, double, double, double);
double addcomplex ()
{
cout << real1 + real2 << " + " << imag1 + imag2 << "i" << endl;
}
double subcomplex ()
{
cout << real1 - real2 << " + " << imag1 - imag2 << "i" << endl;
}
};
Complex::Complex (double a, double b, double c, double d)
{
real1 = a;
real2 = b;
imag1 = c;
imag2 = d;
}
int main ()
{
int g,h,j,k;
cout << "enter first real number" << endl;
cin >> g;
cout << "enter second real number" << endl;
cin >> h;
cout << "enter first imaginary number" << endl;
cin >> j;
cout << "enter second imaginary number" << endl;
cin >> k;
Complex beast (g,h,j,k);
cout << beast.addcomplex() << endl;
cout << beast.subcomplex() << endl;
return 0;
}
yeah but see gives me an error message
so like it dsiplays the answer but under it it says nan
this is from the compliler after running
enter first real number
5
enter second real number
6
enter first imaginary number
5
enter second imaginary number
6
11 + 11i
nan --- i want this gone
-1 + -1i
nan --- whats this