Created
April 16, 2014 04:02
-
-
Save stevenpray/10805318 to your computer and use it in GitHub Desktop.
FizzBuzz C
This file contains hidden or 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
/** | |
* FizzBuzz | |
* | |
* A program that prints the numbers from 1 to 100. | |
* Multiples of three print “Fizz” instead of the number, and multiples of five print “Buzz”. | |
* For numbers which are multiples of both three and five print “FizzBuzz”. | |
*/ | |
#include <stdio.h> | |
int main(void) | |
{ | |
for (unsigned int i = 1; i <= 100; i++) { | |
if (i % 15 == 0) { | |
printf("FizzBuzz\n"); | |
} else if (i % 3 == 0) { | |
printf("Fizz\n"); | |
} else if (i % 5 == 0){ | |
printf("Buzz\n"); | |
} else { | |
printf("%u\n", i); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test