3 ms·
How would you handle a case where it's not divisible by either? We need to handle a conditional that evaluates to true when the number is not divisible by eithe
by lxe 12y ago
How would you handle a case where it's not divisible by either? We need to handle a conditional that evaluates to true when the number is not divisible by either 3 or 5:
#include <stdio.h>
void main()
{
unsigned int i, is3, is5;
for (i = 1; i < 101; i++)
{
is3 = i % 3 == 0;
is5 = i % 5 == 0;
// If both are true,
// FizzBuzz gets printed
if (is3) printf("Fizz");
if (is5) printf("Buzz");
// Still need to handle
// the raw number though
if (!is3 && !is5) printf("%i", i);
printf("\n");
}
}