Saturday, 24 November 2012

DeBUG this C-Bug

A very small challenging question in C....

if(condition)
    printf("Hello");
else
    printf("Bye");

Q: You have to Enter a Condition in if statement so that the program outputs "HelloBye" without quotes..

Answer the question by making it a comment at below the program with your correct name...


thank you
-Gaurav Singhal..

7 comments:

viscrisn said...
This comment has been removed by the author.
viscrisn said...

if(!printf("Hello"))
printf("Hello");
else
printf("Bye");

sparsh parnami said...

condition = printf("Hello") == 1

gaurav singhal said...

if( printf("Hello") ? 0 : 1 )
printf("Hello");
else
printf("Bye");

iSid said...

if(printf("Hello")||0)

Alex said...

isid it will not work...as printf return 5 on execution hence the condition become true and it results in hellohello

Gaurav Singhal said...

anabik this runs but u ust also think about the efficiency of a program....