0

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

Edited by Valiantangel: xxx

3
Contributors
3
Replies
5
Views
4 Years
Discussion Span
Last Post by zeroliken
Featured Replies
  • 1

    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? Read More

  • > 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` Read More

1

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?

0

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
1

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.