Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
  2.  
  3. void main() {
  4. for (int i = 1; i <= 100; i++) {
  5. bool a = i % 3 == 0;
  6. bool b = i % 5 == 0;
  7.  
  8. if (a && b) {
  9. print("FizzBuzz");
  10. } else if (a) {
  11. print("Fizz");
  12. } else if (b) {
  13. print("Buzz");
  14. } else {
  15. print(i);
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement