C++ Question

i get an error "expression can't be used as a function "

#include <iostream>

using namespace std;
int main()
float x;
float y;
cin >> x;
y = (7*((x-3)^2)-6(x-4)+5) ;

return 0;

Why does this keep giving me error "expression can't be used as a function " ?

Answer Source

It's a syntax issue:

y = (7*((x-3)^2)-6(x-4)+5) ;

You need to explicitly multiply otherwise it looks like you are trying to call the function 6:

y = (7*((x-3)^2)-6*(x-4)+5) ;

Then you will need to deal with the error that results from trying to do a bitwise XOR (the ^ operator is bitwise XOR) with a float and an int.

test.cpp:9:19: error: invalid operands of types ‘float’ and ‘int’ to binary ‘operator^’

If you instead meant to use a power you will need to do that differently. See http://en.cppreference.com/w/cpp/numeric/math/pow