invalid suffix "x" on integer constant

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?
Write 4 * x if that is what you mean.
No, I meant x^4, but it doesn't work, if I write like that
The ^ symbol is the exclusive or symbol, not the power symbol. You need to use pow() like the other areas in this calculation
x^4 mean what do you want?
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.
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
Topic archived. No new replies allowed.