Tuesday, September 22, 2009

printf() interview question ....

Look at the code below.


void main()
{
if(X)
{
printf("Hello");
}
else
{
printf(" World");
}
}



What should X be replaced with inorder to get the output as "Hello World"?



3 comments:

  1. main()
    {
    if(printf("Hello") -5 )
    {
    printf("Hello");
    }
    else
    {
    printf(" World");
    }
    }

    ReplyDelete
  2. int main()
    {
    if(!(printf("Hello")))
    {
    printf("Hello");
    }
    else
    {
    printf(" World");
    }
    return 0;
    }
    :)

    ReplyDelete
  3. both of you are correct .. congrats .. :)

    ReplyDelete

About Me

My photo
Hi Friends, I am Samarth currently pursuing my Masters degree in Information Technology from International Institute of Information Technology ,Bangalore .