Skip to content

Instantly share code, notes, and snippets.

@ggramaize
Last active January 18, 2022 16:21
Show Gist options
  • Save ggramaize/3bb078c0b37717951b5ded8fedf9a616 to your computer and use it in GitHub Desktop.
Save ggramaize/3bb078c0b37717951b5ded8fedf9a616 to your computer and use it in GitHub Desktop.
FizzBuzz
#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