|
I am having trouble compiling my program after I input the string for the magnitude. I dont know if there is something I am missing in the string or not, and when I compile I get this error message:
complex_experiment.cpp: In function âint main()â: complex_experiment.cpp:28: error: expected primary-expression before â[â token
Here is my code. I hope someone can help me.
#include<iostream> #include<complex> using std::complex; using namespace std; int main() { double real xa, imag(ya); double xb, yb; complex<double> number(real, imag); cout << "Enter the real and imaginary parts of a complex number: \n"; cin >> xa >> ya; cout << "Enter the parts for another complex number: \n"; cin >> xb >> yb; while (xa >= xb) { cout << "Coordinate 1 = " << xa << ", " << ya << "\n"; cout << "Co. 2 = " << xb << ", " << yb << "\n"; cout << "Co. 1 + Co. 2 = " << xa + xb << ", " << ya + yb << "\n"; cout << "Co. 1 - Co. 2 = " << xa - xb << ", " << ya - yb << "\n"; cout << "Co. 1 * Co. 2 = " << xa * xb << ", " << ya * yb << "\n"; cout << "Co. 1 / Co. 2 = " << xa / xb << ", " << ya / yb << "\n"; cout << "Co. 1 real part = " << xa << "\n"; cout << "Co. 1 imaginary part = " << ya << "\n"; cout << "Magnitude of Co. 1 = " << abs([xa, ya]) << "\n"; } return 0; }
I am trying to do: Call real() and imag() ON a complex number, each gives a result. PASS a complex number to the abs() function, it returns the magnitude.
I am completely confused as to what to do. Any help would be greatly appreciated.
|