Skip to content

Instantly share code, notes, and snippets.

@klange
Created February 15, 2012 05:28
Show Gist options
  • Save klange/1833499 to your computer and use it in GitHub Desktop.
Save klange/1833499 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char * argv[]) {
int i;
for (i = 1; i <= 100; ++i) {
if ((i % 5) && (i % 3)) {
printf("%d", i);
} else {
if (!(i % 3)) {
printf("Fizz");
}
if (!(i % 5)) {
printf("Buzz");
}
}
printf("\n");
}
return 0;
}
@Cloudef
Copy link

Cloudef commented Feb 15, 2012

That's some old article... My try!

#include <stdio.h>
#include <stdlib.h>

int main() {
   int x=1;
   for(;x!=101;++x)
      printf("%.0d%s\n",((x%3)&&(x%5))?x:0,
      (!(x%3)&&!(x%5))?"FizzBuzz":(!(x%3))?"Fizz":(!(x%5))?"Buzz":"");
   return EXIT_SUCCESS;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment