Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions C program to solve Polynomial and Differential Equations
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <stdio.h>
#include <conio.h>

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", &deg);

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;
}