help with error checking

I'm supposed to write a program that reads two numbers and stores them into varialbes double x, y; and then the code is supposed to find the values of x^y and y^x and store them into double xtoy, ytox; And lastly, the code is supposed to determine whether the xtoy is greater/equal/smaller than yto x.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <math.h>
using namespace std;

int main () {
double x, y;
cout<<"Enter a value for x: "<< endl;
cin>> x >> endl;
cout<<"Enter a value for y: "<< endl;
cin>> y >> endl;
double xtoy, ytox;
xtoy = pow(x,y);
ytox = pow(y,x);
if (xtoy>ytox) {
cout << xtoy << " is greater than " << ytox << endl;
}
else if (xtoy<ytox) {
cout << xtoy << " is less than " << ytox << endl;
}
else if (xtoy==ytox) {
cout << xtoy << " is equal to " << ytox << endl;
}

return 0;
}


Please help me find my errors. Thanks
It would be nice if you post any error messages.
Use cin>>x; without the endl;
Topic archived. No new replies allowed.