fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main() {
  5. double step;
  6. double x0 = 1.0;
  7. double y0 = 1.0;
  8. double diffY;
  9. std::cout << std::fixed;
  10. std::cout << std::setprecision(16);
  11. cout << "Enter step value: ";
  12. cin >> step;
  13. float eps = step/10000;
  14. while (x0 <= 2.5 + eps ) {
  15.  
  16. diffY = x0 + ((3*y0) / x0);
  17. cout << x0 << " " << y0 << "\n";
  18. x0+=step;
  19. std::cout << x0 << std::endl;
  20. y0+=step*(diffY);
  21. }
  22.  
  23. return 0; //initially defined the main function to return an int
  24. }
Success #stdin #stdout 0s 3472KB
stdin
0.1
stdout
Enter step value: 1.0000000000000000    1.0000000000000000
1.1000000000000001
1.1000000000000001    1.3999999999999999
1.2000000000000002
1.2000000000000002    1.8918181818181818
1.3000000000000003
1.3000000000000003    2.4847727272727274
1.4000000000000004
1.4000000000000004    3.1881818181818180
1.5000000000000004
1.5000000000000004    4.0113636363636358
1.6000000000000005
1.6000000000000005    4.9636363636363630
1.7000000000000006
1.7000000000000006    6.0543181818181804
1.8000000000000007
1.8000000000000007    7.2927272727272703
1.9000000000000008
1.9000000000000008    8.6881818181818158
2.0000000000000009
2.0000000000000009    10.2499999999999964
2.1000000000000010
2.1000000000000010    11.9874999999999954
2.2000000000000011
2.2000000000000011    13.9099999999999948
2.3000000000000012
2.3000000000000012    16.0268181818181752
2.4000000000000012
2.4000000000000012    18.3472727272727205
2.5000000000000013
2.5000000000000013    20.8806818181818095
2.6000000000000014