Tuesday, May 8, 2007

#47

What is the “condition” such that .. this snippet of code prints HelloWorld!!

if condition
printf(”Hello);
else
print(”World!!);

Answer:

    This problem ... tampered my senses a lot .. and after asking a lot of people ... i could manage a very ordinary solution ... And still not satisfied with that ... I look for a solution ... where the condition would be suh that both parts get executed.. though its a falacy or WRONG in the words of compiler .. The current irritating solution is:

    if ( printf(”Hello”)<0)>
    printf(”Hello”);
    else
    printf(”World!!);

    There seems to be another solution by writing just one more line:

    #define else ;

No comments: