Guest User

Untitled

a guest
Oct 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /* FizzBuzz problem
  2. Write a program that prints the numbers from 1 to 100. But for multiples
  3. of three print “Fizz” instead of the number and for the multiples of five
  4. print “Buzz.” For numbers which are multiples of both three and five print “FizzBuzz.” */
  5.  
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. for (int i = 1; i <= 100; i++)
  12. {
  13. if (i % 3 == 0)
  14. cout << "Fizz" << endl;
  15.  
  16. else if (i % 5 == 0)
  17. cout << "Buzz" << endl;
  18.  
  19. else if (i % 3 == 0 && i % 5 == 0)
  20. cout << "FizzBuzz" << endl;
  21.  
  22. else
  23. cout << i << endl;
  24.  
  25. } // end for
  26.  
  27. return 0;
  28. } // end main
Add Comment
Please, Sign In to add comment