Actually, the control flow only requires you to know that you've done SOMETHING out of the ordinary, but not WHAT you've done. A C example that is easily extensible:<p><pre><code> void fizzBuzz(void)
{
bool alternateUsed = false;
for(int i = 1; i <= 100; i++)
{
if(i % 3 == 0)
{
printf("Fizz");
alternateUsed = true;
}
if(i % 5 == 0)
{
printf("Buzz");
alternateUsed = true;
}
if(!alternateUsed)
{
printf("%d", i);
}
printf("\n");
alternateUsed = false;
}
}
</code></pre>
All you need to know for the decision to print the bare number is whether an alternate (Fizz or Buzz) was used in this iteration. Furthermore, FizzBuzz is described such that you stack alternates (FizzBuzz for values that are multiples of 3 and 5). In this example, they stack automatically, with the order of "if" statements determining the priority. Want to change it to print "BuzzBazzFizz" for multiples of 5, 4, and 3? No problem!<p><pre><code> if(i % 5 == 0)
{
printf("Buzz");
alternateUsed = true;
}
if(i % 4 == 0)
{
printf("Bazz");
alternateUsed = true;
}
if(i % 3 == 0)
{
printf("Fizz");
alternateUsed = true;
}
</code></pre>
Yes, imperative languages can be a bit cumbersome at times, but elegant solutions are still possible.