fork download
  1. #include <iostream>
  2.  
  3.  
  4. void increment_display(int userChoice)
  5. {
  6. std::cout << "increment_display:" << userChoice << std::endl;
  7. for (int i = 0; i < userChoice; ++i)
  8. {
  9. std::cout << "Loop " << i + 1 << ": " << userChoice - i << std::endl;
  10. }
  11. }
  12.  
  13. void decrement_display(int userChoice)
  14. {
  15. std::cout << "decrement_display:" << userChoice << std::endl;
  16. for (int i = userChoice; i != 0; --i)
  17. {
  18. std::cout << "Loop " << userChoice - i + 1 << ": " << i << std::endl;
  19. }
  20. }
  21.  
  22.  
  23. int main() {
  24. increment_display(5);
  25. decrement_display(5);
  26. }
  27.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
increment_display:5
Loop 1: 5
Loop 2: 4
Loop 3: 3
Loop 4: 2
Loop 5: 1
decrement_display:5
Loop 1: 5
Loop 2: 4
Loop 3: 3
Loop 4: 2
Loop 5: 1