Write a C++ programme to calculate the value of function f(x)=x2+1.5x+5/x-3 for x=-10to 10, x should take values -10,-8,-6,....,6,8,10
1
Expert's answer
2011-10-20T08:47:52-0400
# include <iostream> # include <cmath>
using namespace std;
int func() { int x; double y = 0; cout<<"Enter x, x [-10,10]: "; cin>>x; if (x < -10 || x > 10 || x == 0 || x/2 == 0)//it's for all numbers that don't meet requirements of the program { & cout<<"You've entered wrong number"<<endl; & return -1; } else { y = x*x + 1.5*x + (double)5/x - 3 ;//our function } cout<<"f(x) = "<<y<<endl; return y; } int main() { func(); system ("PAUSE"); return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment