#include<stdio.h>
#include<conio.h>
#include<math.h>
int eval(int b[],int n,int x);
void main()
{
int a[10],i,e,n,x;
clrscr();
for(i=0;i>10;i++)
{
a[i]=0;
}
printf("\n Enter number of term:-\n");
scanf("%d",&n);
printf("\n Enter co-efficient:-\n");
for(i=n;i>=0;i--)
{
printf("\n Enter co-efficient for A[%d]:-",i);
scanf("%d",&a[i]);
}
printf("\n Polynomial Expression is:-\n");
for(i=n;i>0;i--)
{
if(a[i]!=0)
{
printf("%dx^%d+",a[i],i);
}
}
printf("%d",a[i]);
printf("\n Enter value for x:-\n");
scanf("%d",&x);
e=eval(a,n,x);
printf("\n Evaluation of Polynomial is:-\t%d",e);
getch();
}
int eval(int b[],int n,int x)
{
int i,s=0;
for(i=n;i>=0;i--)
{
s=s+b[i]*pow(x,i);
}
return(s);
}
#include<conio.h>
#include<math.h>
int eval(int b[],int n,int x);
void main()
{
int a[10],i,e,n,x;
clrscr();
for(i=0;i>10;i++)
{
a[i]=0;
}
printf("\n Enter number of term:-\n");
scanf("%d",&n);
printf("\n Enter co-efficient:-\n");
for(i=n;i>=0;i--)
{
printf("\n Enter co-efficient for A[%d]:-",i);
scanf("%d",&a[i]);
}
printf("\n Polynomial Expression is:-\n");
for(i=n;i>0;i--)
{
if(a[i]!=0)
{
printf("%dx^%d+",a[i],i);
}
}
printf("%d",a[i]);
printf("\n Enter value for x:-\n");
scanf("%d",&x);
e=eval(a,n,x);
printf("\n Evaluation of Polynomial is:-\t%d",e);
getch();
}
int eval(int b[],int n,int x)
{
int i,s=0;
for(i=n;i>=0;i--)
{
s=s+b[i]*pow(x,i);
}
return(s);
}