My fizzbuzz in C

11 04 2013

This is my version of the fizzbuzz test, written in C:

char *arr[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"}; 
for (int i=1; i<=100; i++) printf(arr[!(i%3)+2*!(i%5)], i);

or rephrased in a more readable format:

char *arr[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"}; 

int i, index;

for (i=1; i<=100; i++)
{
	index = !(i%3) + 2 * !(i%5);
	printf( arr[index], i);
}
Advertisements

Actions

Information

2 responses

27 07 2013
Free Classified

Thanks for this post, it helpfull for me

31 03 2014
Gladys

I think the admin of this web page is genuinely working hard in support of his site, as here every stuff is quality based material.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: