Hacker News new | ask | show | jobs
by rhth54656 4455 days ago
Don't ruin that version with an if statement.

Use this and avoid it( and the second array as well ):

  char * a[] = { "%d\n" , "Fizz\n" , "Buzz\n" , "FizzBuzz\n" } ;
1 comments

Brilliant, thanks! The C version is now:

    int i; char* a[] = { "%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" };
    for ( i = 1; i < 101; i++ )
        printf( a[ (i%5==0)*2 + (i%3==0) ], i );