Advertisement
double_trouble

Nastya1

Apr 8th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. void print_f1(double a, double b)
  9. {
  10.     double step = (b - a + 1) / 10.0;
  11.  
  12.     cout << endl;
  13.     cout << "Function 1: y = 5x + 16" << endl;
  14.     double x = a;
  15.     while (x <= b)
  16.     {
  17.         cout << fixed;
  18.         cout << setprecision(3) << "X = " << x << " Y = " << 5 * x + 16 << endl;
  19.         x += step;
  20.     }
  21. }
  22.  
  23. void print_f2(double a, double b)
  24. {
  25.     double step = (b - a) / 9.0;
  26.  
  27.     cout << endl;
  28.     cout << "Function 2: y = sin(8x)" << endl;
  29.     double x = a;
  30.     while (x <= b)
  31.     {
  32.         cout << fixed;
  33.         cout << setprecision(3) << "X = " << x << " Y = " << sin(8 * x) << endl;
  34.         x += step;
  35.     }
  36. }
  37.  
  38. int main()
  39. {
  40.     double a, b;
  41.     cout << "Enter interval limits [a, b] : " << endl;
  42.     cin >> a >> b;
  43.     print_f1(a, b);
  44.     print_f2(a, b);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement