peterzig

5. FizzBuzz

Sep 19th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream>
  3. int main()
  4. {
  5.     for (int i = 1; i <= 100; ++i)
  6.     {
  7.         std::cout << i << '\r'; // return to beginning of line for overwriting with "Fizz" or "Buzz"
  8.         if (i % 3 == 0) std::cout << "Fizz";
  9.         if (i % 5 == 0) std::cout << "Buzz";
  10.         std::cout << '\n';
  11.     }
  12.     _getch();
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment