The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.
However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.
Code:
#include <stdio.h>
int main(void)
{
int x, polynomial;
printf("The program will compute the following polynomial: \n");
printf("3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6 \n");
printf("Please enter a value for x: ");
scanf("%d", &x);
polynomial = (3 * x * x * x * x * x) + (2 * x * x * x * x) - (5 * x * x * x) - (2 * x * x) + (7 * x) - 6;
printf("Value = %d \n", polynomial);
return 0;
}