Skip to content

Instantly share code, notes, and snippets.

@Thelta
Last active April 8, 2018 20:30
Show Gist options
  • Save Thelta/1a5067f664214ba3d012525e10fda51d to your computer and use it in GitHub Desktop.
Save Thelta/1a5067f664214ba3d012525e10fda51d to your computer and use it in GitHub Desktop.
FizzBuzz (But if never used)
#include <stdio.h>
char number[5] = "\0";
void fizz(int a)
{
printf("fizz");
sprintf(number, " %d\n", a);
}
void buzz(int a)
{
printf("buzz");
sprintf(number, " %d\n", a);
}
void none(int a)
{
}
void (*fizzFunc[]) (int) = { fizz, none, none };
void (*buzzFunc[]) (int) = { buzz, none, none, none, none };
int main(void)
{
int i = 0;
for(i = 0; i < 121; i++)
{
fizzFunc[i % 3](i);
buzzFunc[i % 5](i);
printf(number);
number[0] = '\0';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment