4 ms·
You don't actually need the modulo operator though. Modulo is effectively x - x * (x/y) with integers but you don't even need that. You can do something like
by lsiebert 11y ago
You don't actually need the modulo operator though.
Modulo is effectively x - x * (x/y) with integers but you don't even need that.
You can do something like this.
#include <stdio.h>
#include <stdbool.h>
int main(void) {
int five = 5;
int three = 3;
int count;
bool numprint;
for (count = 1; count <= 100; count++){
numprint = true;
if (count - three == 0) {
three += 3;
printf("Fizz");
numprint = false;
}
if (count - five == 0) {
five += 5;
printf("Buzz");
numprint = false;
}
if (numprint) {
printf("%d", count);
}
printf("\n");
}
return 0;
}