Я пытаюсь получить значение полиномиальной функции с возвращаемым значением, но кажется, что что-то не так с переменными.
Возможно, я ошибся, записывая уравнение ряда внутри функции. Но отладить код тоже не удалось, так как он неожиданно вылетает.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
double PolinomHesapla(double *p, int N, double x)
{
double total = 0;
int j;
for (j=0; j < N; j++)
{
total += p[j] * pow(x,N);
}
return total;
}
int main(int argc, char *argv[]) {
double x_point;
int n;
int i; // iteration variable
double a[n]; // we put the coefficients inside a[n] array
printf("Enter the order of the polynomial function: ");
scanf("%d", &n);
printf("Enter the coefficients of the function: ");
for(i=0; i < n ; i++)
{
scanf("%f",&a[i]);
}
printf("Enter the point of x in the function\t:");
scanf("%f",&x_point);
printf("The value of the function at that point is\t %f",PolinomHesapla(a,n,x_point)); // we send the values
// into PolinomHesapla function
return 0;
}