c This program evaluates polynomials. The user inputs the degree
c and the coefficients of the polynomial, and a point where the
c polynomial is to be evaluated. A function subprogram evaluates
c the polynomial at the point.
real a(0:20), x, poly
print *, "What is the degree of the polynomial?"
print *, "(no more than 20, please)"
read *, n
do i = 0, n
print *, "Enter the coefficient of the term of degree", i
read *, a(i)
5 print *, "What is the point x of interest?"
read *, x
print *, "The value of the polynomial there is", poly(a,x,n)
print *, "Do you want to evaluate at another point (y or n)?"
if (ans .eq. "y" .or. ans .eq. "Y") go to 5
print *, "OK, then - bye"
real poly, a(0:20), x
poly = a(0)
xpower = 1
do i=1, n
xpower = xpower * x
poly = poly + a(i) * xpower