Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- * Write a program that prints the numbers from 1 to 100. But for multiples of
- * three print "Fizz" instead of the number and for the multiples of five
- * print "Buzz". For numbers which are multiples of both three and five print
- * "FizzBuzz".
- */
- #define CHECK_MULT(num) (((buf = (float) index / num) == (int) buf) << (num / 5))
- int main(int argc, char **argv) {
- float buf;
- int index;
- unsigned char mult;
- for(index = 1; index <= 100; index++) {
- mult = 0;
- if(((mult |= CHECK_MULT(3)) & 1))
- printf("Fizz");
- if(((mult |= CHECK_MULT(5)) & 2))
- printf("Buzz");
- if(!mult)
- printf("%i", index);
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment