invalid suffix "x" on integer constant

Jan 7, 2013 at 5:53pm
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
   double x, y;
   cin >> x;
   y = (sqrt(pow(x, 4) + 3)) / (abs(pow(x, 2) + 5)) + 4x;
   cout << y ;
   return 0;
}


I'm getting an error: invalid suffix "x" on integer constant, on row 9. How to fix it?
Jan 7, 2013 at 5:55pm
Write 4 * x if that is what you mean.
Jan 9, 2013 at 6:00am
No, I meant x^4, but it doesn't work, if I write like that
Jan 9, 2013 at 6:07am
The ^ symbol is the exclusive or symbol, not the power symbol. You need to use pow() like the other areas in this calculation
Jan 9, 2013 at 9:23am
x^4 mean what do you want?
Jan 9, 2013 at 8:41pm
I meant x*x*x*x, but this way it still doesn't work. It gives me the same error: invalid suffix "x" on integer constant on row 9.
Jan 9, 2013 at 10:02pm
Just use pow() with the appropriate arguments. It's already there in the code, just copy + paste it as required.

Or simply put x*x*x*x if you like.
Last edited on Jan 9, 2013 at 10:06pm
Topic archived. No new replies allowed.