Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

fizzbuzz

Name: Anonymous 2011-03-25 23:20

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”.

Language: C
Difficulty: One line of code (i.e. one semicolon).

Shortest program wins.

Name: Anonymous 2011-03-26 7:36

>>10 I messed up quotes by one.

Also using argc instead of variable declaration we can write even shorter vesrion.


//10
main(){int x=0;for(;++x-101;)printf(x%5?x%3?"%d\n":"fizz\n":x%3?"buzz\n":"fizzbuzz\n",x);}
//new
main(x){for(x=0;++x-101;)printf(x%5?x%3?"%d\n":"fizz\n":x%3?"buzz\n":"fizzbuzz\n",x);}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List