Solution: FizzBuzz

Solution: FizzBuzz

C
#include <stdio.h>
int main(void)
{
int i;
for (i = 1; i <= 100; i++) {
// If the number is divisible by 3, remainder will be 0
// We use the operator ! to change 0 to 1 so that the overall
// condition becomes true
if (!(i % 3) && !(i % 5)) // Check if it's divisible by 3 and 5 by taking % (modulo) 3 and 5
printf("FizzBuzz");
else if (!(i % 3)) // Check if it's divisible by just 3
printf("Fizz");
else if (!(i % 5)) // Check if it's divisible by just 5
printf("Buzz");
else
printf("%d", i);
printf("\n");
}
return 0;
}