Advertisement
dmzem

Untitled

Dec 1st, 2022
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void solver(float x){
  6.     cout << "Answer (y) is ";
  7.     if(x > 7){
  8.         cout << 1 / (x - 7) << endl;
  9.     }
  10.     else{
  11.         cout << -3*x + 9 << endl;
  12.     }
  13. }
  14.  
  15. int main()
  16. {
  17.     float x;
  18.     cout << "Solver for function" << endl;
  19.     cout << "       −3𝑥 + 9 (when) x ≤ 7" << endl;
  20.     cout << "f(x) = " << endl;
  21.     cout << "        1 / (x - 7)" << endl;
  22.     cout << "Enter your x: ";
  23.     cin >> x;
  24.     solver(x);
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement