B.T: Print “HelloWord”

What is the “condition” so that the following code prints both HelloWorld !
      if  “condition”
          printf (“Hello”);
      else
          printf(“World”);

Solution:
         #include<stdio.h>
         intmain()
         {
             if(!printf(“Hello”))
                 printf(“Hello”);
            else
                printf(“World”);
           getchar();
         }       
Explanation: Printf returns the number of character it has printed successfully. So, following solutions will also work
if (printf(“Hello”) < 0) or
if (printf(“Hello”) < 1) etc
 
Please Comment on solution and try to give more solution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: