Answer to Question #310822 in C++ for Diya

Question #310822

3. Write a program that asks the user to enter a value for x and then displays the value of the following polynomial 2x^5+3x^4-x^3-2x^2+7x-6.

1
Expert's answer
2022-03-13T11:22:37-0400
#include <iostream>
using namespace std;


double f(double x) {
    return ((((2.0*x + 3.0)*x - 1.0)*x - 2.0)*x + 7.0)*x - 6.0;
}


int main() {
    double x, y;


    cout << "Enter a value x: ";
    cin >> x;


    y = f(x);
    cout << "2x^5+3x^4-x^3-2x^2+7x-6 = " << y << endl;

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment