/* Write a funtion which takes an array of coefficients,ai and an integer n, and returns
the value of the following equation. Also write a code fragment to show how to call your
function.
y=a0+a1x+a2x^2+a3x^3+...anx^n
*/
#include <iostream>
#include <cmath>
usingnamespace std;
// define power function
double series(int n, double ai[n], double x);
int main(void)
{
double x;
int n;
double ai;
{
cout<<"Please enter a group of numbers"<< endl;
cin>>ai[n];
cout<<"enter an x value"<< endl;
cin>>x;
y=series(ai[n],n,x);
}
}
double series(int n, double ai[], double x)
{
double y=0;
for (int i=n; i>=0;i--)
{
y=y+ai[i]*pow(x,i);
}
return y;
}