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:

  1. This comment has been removed by the author.

    ReplyDelete
  2. if(!printf("Hello"))
    printf("Hello");
    else
    printf("Bye");

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

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

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

    ReplyDelete