Last active
September 20, 2021 13:24
-
-
Save Riverfount/c936edb53cef2a7420b6041ae5446369 to your computer and use it in GitHub Desktop.
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 <stdlib.h> | |
int main(int argc, char *argv[]){ | |
if (argc <= 1){ | |
printf( | |
"É necessário passar um argumento inteiro!\n" | |
"Uso correto: fizzbuzz <int>\n" | |
); | |
return 1; | |
} else { | |
int number = atoi(argv[1]); | |
if (number % 3 == 0 && number % 5 == 0){ | |
printf("fizzbuzz\n"); | |
} else if (number % 3 == 0){ | |
printf("fizz\n"); | |
} else if (number % 5 == 0){ | |
printf("buzz\n"); | |
} else { | |
printf("%d\n", number); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment