Calculate for a value X data of type float the numerical value of a polynomial of degree N
C Code: Program to find the value of the polynomial
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <stdio.h> #include <stdlib.h> #include <math.h> main() { float A[30]; int N; float X; float P; printf("Enter the degree N of the polynomial (30 maximum): "); scanf("%d", &N); printf("Enter the value of the variable X: "); scanf("%f", &X); for (int i=0 ; i<=N ; i++) { printf("Enter the coefficient A %d:", i); scanf("%f", &A[i]); } P=0.0; for (int i=0 ; i<=N ; i++) P += A[i]*pow(X,i); printf("Polynomial value for X =%.2f: %.2f\n", X, P); system("pause"); } |