I am getting an error fors x in the polynomial expression.If i put my cursor it says Expected:a';'

``````Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
``````
include<stdio.h>
include<stdlib.h>

int main(void)
{

``````double x=2.55;
double polynomial=3x^3-5x^2+6;

printf("The value of polynomial is %lf\n",polynomial);

system("pause");

return(EXIT_SUCCESS);
``````

}

``````Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
``````

Thanks

## All 3 Replies

Just taking the first part of the equation - 3x^3
To multiply you need to use * as in 3*x
^ is bitwise xor, do you really want to calculate 3 times x xor 3?

Thanks managed to solve it.But just 1 more question, if i want to make x the constant or in c u call define.,how can i go about? Below is my solved equation

``````Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
``````
include<stdio.h>
include<stdlib.h>
include<math.h>

int main(void)
{

``````double x=2.55;
double polynomial=3.0*x*x*x-5.0*x*x+6.0;                /*this is similar to 3.0*pow(x,3)-5.0*pow(x,2)+6;*/

printf("The value of polynomial is %lf\n",polynomial);

system("pause");

return(EXIT_SUCCESS);
``````

}

``````Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
``````

if i want to make x the constant or in c u call define.,how can i go about?

before main,
`#define x 2.55`

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.