From 77c08b4d16c3d349681ee1414329f789ed1b5377 Mon Sep 17 00:00:00 2001 From: Shreya Gautam Date: Fri, 8 Oct 2021 18:52:18 +0530 Subject: [PATCH] C program to solve Polynomial and Differential Equations --- ...olve Polynomial and Differential Equations | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 C program to solve Polynomial and Differential Equations diff --git a/C program to solve Polynomial and Differential Equations b/C program to solve Polynomial and Differential Equations new file mode 100644 index 0000000..fcf13ad --- /dev/null +++ b/C program to solve Polynomial and Differential Equations @@ -0,0 +1,42 @@ +#include +#include + +float poly(float a[], int, float); + +int main() +{ + float x, a[10], y1; + int deg, i; + + printf("Enter the degree of polynomial equation: "); + scanf("%d", °); + + printf("Ehter the value of x for which the equation is to be evaluated: "); + scanf("%f", &x); + + for (i = 0; i <= deg; i++) { + printf("Enter the coefficient of x to the power %d: ", i); + scanf("%f", &a[i]); + } + + y1 = poly(a, deg, x); + + printf("The value of polynomial equation for the value of x = %.2f is: %.2f", x, y1); + + return 0; +} + +/* function for finding the value of polynomial at some value of x */ +float poly(float a[], int deg, float x) +{ + float p; + int i; + + p = a[deg]; + + for (i = deg; i >= 1; i--) { + p = (a[i - 1] + x * p); + } + + return p; +}