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
# 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;
}