Last active
January 18, 2019 11:59
-
-
Save simontime/a60e710d5035677426d3ae6dce1796c7 to your computer and use it in GitHub Desktop.
Best and shortest fizzbuzz in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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