Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. float n;
  6. int k = 0;
  7. cout << "n="; cin >> n;
  8. if (n > 0)
  9. {
  10. while (n >= 1)
  11. {
  12. n = n - 1;
  13. k++;
  14. }
  15. cout << k;
  16. }
  17. else
  18. if (n < 0)
  19. {
  20. while (n < 0)
  21. {
  22. n = n + 1;
  23. k++;
  24. }
  25. cout << -k;
  26. }
  27.  
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement