by CodeChum Admin
Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with rules of math applied since math is fun, right?
Just print out "Fizz" when the given number is divisible by 3, "Buzz" when it's divisible by 5, and "FizzBuzz" when it's divisible by both 3 and 5!
#include <stdio.h>
int main()
{
int number;
printf("Enter a Number: ");
scanf("%d", &number);
printf("\n");
if ((number % 3 == 0) && (number % 5 == 0))
printf("\nFizzBuzz");
else if (number % 3 == 0)
printf("\nFizz");
else
printf("\nBuzz");
}
Comments
Leave a comment