#include struct poly { float a, // fourth degree coefficient b, // third degree coefficient c,d,e; }; void read_in_coeff(poly & p); float get_val_of_name(char name); float F(poly the_polynomial, float x); void print_poly(poly p, float x, float y); int main () { poly p; float x=0,y=5; read_in_coeff(p) ; x = get_val_of_name('x'); y = F(p,x); print_poly(p,x,y); return(0); } void read_in_coeff(poly & p) { cout << "Please enter the coefficients for the polynomial " << endl; cout << " ax^4+bx^3+cx^2+dx+e" << endl; p.a = get_val_of_name('a'); p.b = get_val_of_name('b'); p.c = get_val_of_name('c'); p.d = get_val_of_name('d'); p.e = get_val_of_name('e'); } float get_val_of_name( char name){ float rv; cout << "Please enter a value for " << name << endl; cout << "=> "; cin >> rv; return(rv); } float F(poly the_polynomial, float x){ float rv; // // this is using horner's method for evaluating a polynomial // rv = ((((the_polynomial.a*x) +the_polynomial.b)*x +the_polynomial.c)*x +the_polynomial.d)*x +the_polynomial.e; return(rv); } void print_poly(poly p, float x, float y){ cout << "F("<< x << ") ="<