Created
October 7, 2020 03:48
-
-
Save snghnishant/faf3d86d74a140701f41f117dc5eb388 to your computer and use it in GitHub Desktop.
FizzBuzz in C
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 <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