Advertisement
Guest User

c++

a guest
Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double f(double x) //function f(x)
  6. {
  7.     return -2.4*pow(x,2) + 5*x - 3;
  8. }
  9.  
  10. int main()
  11. {
  12.     double a=-2, b=2, h=0.5, x; //variables
  13.  
  14.     cout << "x\tf(x)" << endl; //header of table
  15.  
  16.     for (x=a; x<=b; x+=h)   //cycle
  17.         cout << x << "\t" << f(x) << endl;
  18.  
  19.     getchar(); //pause before closing programm
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement