Hello World in C

shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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's Avatar, Join Date: Aug 2004
Team Leader
How much twist can be impared with just Hello World
coderzone's Avatar, Join Date: Jul 2004
Team Leader
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's Avatar, Join Date: Jul 2004
Team Leader
Quote:
Originally Posted by go4expert
How much twist can be impared with just Hello World
very true