Skip to content

Instantly share code, notes, and snippets.

@snghnishant
Created October 7, 2020 03:48
Show Gist options
  • Save snghnishant/faf3d86d74a140701f41f117dc5eb388 to your computer and use it in GitHub Desktop.
Save snghnishant/faf3d86d74a140701f41f117dc5eb388 to your computer and use it in GitHub Desktop.
FizzBuzz in C
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
int i = 1;
while( i <= 100){
char str[10] = "";
if( i%3 == 0)
strcat(str, "Fizz");
if( i%5 == 0)
strcat(str, "Buzz");
int res = strcmp(str, "");
if( res == 0)
sprintf(str, "%d", i);
printf("%s\n",str);
i++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment