Teaser - 7

1 reply [Last post]
bOtskOOl
Offline
Last seen: 9 years 49 weeks ago
Joined: 2009-02-21
bOt Points: 3500

Hey ppl we are back with Teaser-7 There will be no points for this for the time being as bOt cOntest is made offline for some time but I am sure you will njoy this. One should not post solutions just for prizes aand pOints. Passion for coding should speak aloud. So here comes the question :- What's the "condition" so that the following code snippet prints:- HelloWorld Code Snippet if "condition" printf ("Hello"); else printf("World"); Best Of LuCk!!

aashiqcoolguy21
Offline
Last seen: 9 years 43 weeks ago
Joined: 2009-05-31
bOt Points: 3354
There Are many solutions:

There Are many solutions:

 

1

if ( printf("Hello") == 0 )
    printf
("Hello");
else
    printf
("World");

2.
int main() {
   
if  (printf("Hello"), 0)
        printf
("Hello");
   
else
        printf
("World");
}

3. for unix only....

if  (!fork())
    printf
("Hello");
else
    printf
("World");
4.

if(!(printf("Hello")))
{
}
else
printf(" world");


5.

if (printf("Hello") - strlen("Hello"))
    printf
("Hello")
else
    printf
("World")
if (printf("Hello") - strlen("Hello"))
    printf
("Hello")
else
    printf
("World")
Well There can be lots of other ways also ... !!!