i wrote this program which calculates 8 polynomial degrees at value of x inputted by the user. the program runs, however once i enter the 8 polynomials it should allow me to enter the value of x however it skips, and shows me the output. i tried using floats and doubles in scanner function however that didn't work. any help would be greatly appreciated, thank you.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void get_poly(double *coeff, int N);
double eval_poly(double *coeff, double base, int N);
int main(void)
{
int N = 8;
double res;
double base = 0.0;
double a[N];
double *coeff;
coeff = &a[0];
printf("Enter the eight coeffecients: \n");
scanf(" %d",&N);
get_poly(coeff, N);
printf("Enter x: \n");
scanf(" %lf", &base);
res=eval_poly(coeff, base, N);
printf("Output: %f. \n",res);
return 0;
}
void get_poly(double *coeff, int N)
{
int i = 0;
double placeholder;
for (i = 0; i < N; i++)
{
scanf(" %lf", &placeholder);
*coeff = placeholder;
coeff++;
}
}
double eval_poly(double *coeff, double base, int N)
{
int i = 0;
double res=0.0;
for (i = 0; i < N; i++)
res=res+coeff[i]*pow(base,i);
return res;
}