Last active
January 18, 2022 16:21
-
-
Save ggramaize/3bb078c0b37717951b5ded8fedf9a616 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains 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 <stdlib.h> | |
void nop(void) { ; } | |
void die(void) { exit(1); } | |
void (*die_if_true[])(void) = { nop, die}; | |
int main(void) | |
{ | |
const char *fizzbuzz[] = { "%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" }; | |
size_t i=0; | |
while(1) | |
{ | |
++i; | |
printf( fizzbuzz[(i%5==0)<<1+(i%3==0)], i); | |
die_if_true[i==100](); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment