Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Source: http://4.bp.blogspot.com/-1ixiCqMw2G8/TxXOx9j-giI/AAAAAAAAD7I/flIVf8Ripdk/s1600/15gebnr.png
- * Description:
- * Write a program that prints the numbers from 1 to 100 [including 100]. But
- * for multiples of three print "Fizz" instead of the number and
- * for the multiples of five print "Buzz" [instead of the number].
- * For numbers which are multiples of both three and five print "FizzBuzz" [instead of the number].
- */
- #include <stdio.h>
- #define START 1
- #define END 100
- int divisible(int a, int b){
- return a % b == 0;
- }
- void fbprint(int n){
- int div3 = divisible(n, 3),
- div5 = divisible(n, 5),
- neither = !(div3 || div5);
- if(div3)
- printf("Fizz");
- if(div5)
- printf("Buzz");
- if(neither)
- printf("%i", n);
- putchar('\n');
- }
- int main(){
- int i;
- for(i = START; i <= END; i++)
- fbprint(i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement