I don't know why this doesn't work. It doesn't return any errors, but it does the polynomial equation wrong. I tried using "^" instead of "pow" and it still does it wrong. I'm getting results like "-897123897" instead of "3". This is the code:
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
int i, x[10], e, S = 0;
double y;
printf("Plese insert degree of polynomial\n");
scanf("%d", &e);
printf("Please insert X\t");
scanf("%d", &y);
printf("Please insert coeficient of each degree\n");
for (i = 0; i <= e; i++)
{
scanf("%d", &x[i]);
}
S = 0;
for (i = 0; i <= e; i++)
{
S = S + x[i]*(pow(y,e-i));
}
printf("The value of your polynomial is = %d\n", S);
getch();
}