Complex Numbers
-
I am having a few problems with the following code: int main(){ double a, b, c, d; cout << "Enter the first complex number:"; cin >> a >> b; cout << "Enter the second complex number: "; cin >> c >> d; cout << "(" << a << "+" << b <<"i)" << " + (" << c << d << "i) = "; cout << Sum(a,b,c,d)<< endl; return 0; } double Sum(double& a, double& b, double& c, double& d){ double i; double sum1, sum2; sum1 = (a + c); sum2 = i*(b + d); return (sum1 + sum2); } When go to print the function to the screen will not display (7-i) but instead prints the value 7. How do I get around this problem? :confused:
-
I am having a few problems with the following code: int main(){ double a, b, c, d; cout << "Enter the first complex number:"; cin >> a >> b; cout << "Enter the second complex number: "; cin >> c >> d; cout << "(" << a << "+" << b <<"i)" << " + (" << c << d << "i) = "; cout << Sum(a,b,c,d)<< endl; return 0; } double Sum(double& a, double& b, double& c, double& d){ double i; double sum1, sum2; sum1 = (a + c); sum2 = i*(b + d); return (sum1 + sum2); } When go to print the function to the screen will not display (7-i) but instead prints the value 7. How do I get around this problem? :confused:
Because u didn't identify i the output has some errs.Do not identify i by using double,identify it like characters.And finnaly add it to answer. cout<<(a+c)+(b+d)<<".i"; like this .ok?? However if u want to make some other calculations on complex number theory , you have to identify the special properties of i.