Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Hello World in C (http://www.go4expert.com/forums/hello-world-c-t377/)

shabbir 6Jul2005 12:31

Hello World in C
 
Code:

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

what to be placed in the place of X inorder to get the o/p ??? Hello World

Thanks
Shabbir Bhimani

go4expert 6Jul2005 13:42

Re: Hello World in C
 
How much twist can be impared with just Hello World

coderzone 6Jul2005 13:43

Re: Hello World in C
 
What I can think of is

X = !printf("Hello")

so the program becomes
Code:

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

As printf returns no of characters it prints out so the output would become Hello World as desired

coderzone 6Jul2005 13:51

Re: Hello World in C
 
Quote:

Originally Posted by go4expert
How much twist can be impared with just Hello World

very true :)


All times are GMT +5.5. The time now is 01:33.