ItzEdInYourBed

99bottles.cpp

May 18th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. Your for loop should have a counter that starts at 99:
  2.  
  3. #include <iostream>
  4.  
  5. int main() {
  6.  
  7.   // Write a for loop here:
  8.  
  9.   for (int i = 99; i > 0; i--) {
  10.  
  11.     std::cout << i << " bottles of pop on the wall.\n";
  12.     std::cout << "Take one down and pass it around.\n";
  13.     std::cout << i - 1 << " bottles of pop on the wall.\n\n";
  14.  
  15.   }
  16.  
  17. }
  18. If you want to add the final verse at the end:
  19.  
  20. #include <iostream>
  21.  
  22. int main() {
  23.  
  24.   // Write a for loop here:
  25.  
  26.   for (int i = 99; i > 0; i--) {
  27.  
  28.     std::cout << i << " bottles of pop on the wall.\n";
  29.     std::cout << "Take one down and pass it around.\n";
  30.     std::cout << i - 1 << " bottles of pop on the wall.\n\n";
  31.  
  32.   }
  33.  
  34.   std::cout << "No more bottles of pop on the wall.\n";
  35.   std::cout << "No more bottles of pop.\n";
  36.   std::cout << "Go to the store and buy some more,\n";
  37.   std::cout << "99 bottles of pop on the wall.\n";
  38.  
  39. }
Add Comment
Please, Sign In to add comment