4 ms·
The point of FizzBuzz is that you can give candidates a description of the problem and also give them the mod operator and a sample of its usage and some people
by DanBC 11y ago
The point of FizzBuzz is that you can give candidates a description of the problem and also give them the mod operator and a sample of its usage and some people would still fail.
It would be great if there were some actual research on this. (How many people who claim to be able to program cannot create fizzbuzz in an hour even if you give them a description of modulo)
I suspect that a lot of it comes from "programming sheep and goats", which was later withdrawn by its author.
- lsiebert 11y agoYou 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; }