Skip to content

Instantly share code, notes, and snippets.

@simontime
Last active January 18, 2019 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simontime/a60e710d5035677426d3ae6dce1796c7 to your computer and use it in GitHub Desktop.
Save simontime/a60e710d5035677426d3ae6dce1796c7 to your computer and use it in GitHub Desktop.
Best and shortest fizzbuzz in C
#include <stdio.h>
#include <string.h>
void main() {
for (char i = 1, output[9]; i <= 100; i++, memset(output, 0, 9)) {
if (!(i % 3)) strcpy(output, "Fizz");
if (!(i % 5)) strcpy(!output[0] ? output : output + 4, "Buzz");
printf("%d: %s\n", i, output[0] ? output : "N/A");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment