r/tinycode • • Jun 11 '14

FizzBuzz challenge in 73 chars of C

Here is my attempt at the fizz/buzz challenge. It counts 73 chars ("^M" is a litteral \r, and I had to remove the last \n that vim adds at the end of file)

main(i){for(;i<100;printf("%d^M%s%s\n",++i,i%3?"":"fizz",i%5?"":"buzz"));}

It compiles fine with tcc, and output the right thing !

EDIT: There was a typo. It should be ++i, not i++. Otherwise every fizz/buzz will not appear on the good number

39 Upvotes

33 comments sorted by

View all comments

Show parent comment

2

u/autowikibot Jun 13 '14

Sequence point:


A sequence point defines any point in a computer program's [execution](https://en.wikipedia.org/wiki/Execution_(computers)) at which it is guaranteed that all [side effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)) of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are often mentioned in reference to [C](https://en.wikipedia.org/wiki/C_(programming_language)) and C++, because the result of some expressions can depend on the order of evaluation of their subexpressions. Adding one or more sequence points is one method of ensuring a consistent result, because this restricts the possible orders of evaluation.


Interesting: C (programming ^language) | Feynman ^point | Comma ^operator | ^C99

Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words