A C program to find a sum of series of polynomial
A C program to find the sum of series of polynomial
#include<stdio.h>
#include<math.h>
void main()
{
int i,n,sum,a[20];
float x;
printf(" enter the number of coefficients \n");
scanf("%d",&n);
printf("enter the coefficients\n");
for("i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("enter the value for x\n");
scanf("%f",&x);
sum=0;
for(i=n-1;i>0;i--)
{
sum=sum+a[i]*pow(x,i);
}
printf("result is %d\n",sum);
getch();
clrscr();
}
#include<stdio.h>
#include<math.h>
void main()
{
int i,n,sum,a[20];
float x;
printf(" enter the number of coefficients \n");
scanf("%d",&n);
printf("enter the coefficients\n");
for("i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("enter the value for x\n");
scanf("%f",&x);
sum=0;
for(i=n-1;i>0;i--)
{
sum=sum+a[i]*pow(x,i);
}
printf("result is %d\n",sum);
getch();
clrscr();
}
Comments
Post a Comment