Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9. double x, y;
  10. cout << "enter x:" << endl;
  11. cin >> x;
  12.  
  13. if (x <= 0) {
  14. y = -1 * x;
  15. cout << y << endl;
  16. }
  17. else if ((x > 0) && (x <= 1)) {
  18. y = x;
  19. cout << y << endl;
  20. if ((y < 0) && (y > 1)) {
  21. cout << "out of range:" << endl;
  22. }
  23. }
  24. else if ((x > 1) && (x <= 2)) {
  25. y = 1;
  26. cout << y << endl;
  27.  
  28. }
  29. else if ((x > 2) && (x <= 3)) {
  30. y = -0.5 * (x);
  31. if ((y >= 1) && (y <= -1))
  32. cout << "out of range" << endl;
  33. }
  34.  
  35. system("pause");
  36. return 0;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement