Guest User

Untitled

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