Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** fizzbuzz.c */
- #include <stdio.h>
- #include <string.h>
- #include <assert.h>
- #include <limits.h>
- #include "fizzbuzz.h"
- const char* fizzbuzz(signed long n)
- {
- static char s[20];
- s[0] = '\0';
- if (n % 15 == 0)
- strcat(s, "FizzBuzz");
- else if (n % 3 == 0)
- strcat(s, "Fizz");
- else if (n % 5 == 0)
- strcat(s, "Buzz");
- else
- sprintf(s, "%ld", n);
- return s;
- }
- int main()
- {
- for (int i = 0; i < 100; i++)
- printf("%s\n", fizzbuzz(1 + i));
- return 0;
- }
Add Comment
Please, Sign In to add comment