If… Then… Else…

Here’s a puzzle for the C-programmer in you…

What’s the “condition” so that the output of the following code snippet is:

Hello-World!!


if “condition”
printf (“Hello-“);
else
printf(“World!!”);

Multiple Solutions exist. Lets see who gets the first one. Go go go… 🙂

UPDATE :
People who solved the Puzzle.

Checkout the Hall-of-FAME.

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Advertisements

~ by CVS268 on Thu, 18 Mar, 2010.

7 Responses to “If… Then… Else…”

  1. if(!printf(“Hello-”))
    printf (“Hello-”);
    else
    printf(“World!!”);

  2. int main()
    {
    static int i = 0;
    if(i++ == 0? main() : 1)
    printf(“Hello-“);
    else
    printf(“World”);
    return 0;
    }

  3. if(!fork())
    printf(“Hello “);
    else
    printf(“World”);

  4. if(1)
    printf(“Hello-“);
    else;
    printf(“World!!!”);

  5. if (printf(“Hello-“) * 0)

    printf (“Hello-”);
    else

    printf(“World!!”);

  6. if (0 / printf(“Hello-”))
    printf (“Hello-”);
    else
    printf(“World!!”);

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