Hello World in C

Discussion in 'C' started by shabbir, Jul 6, 2005.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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
     
  2. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    How much twist can be impared with just Hello World
     
  3. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    39
    Trophy Points:
    28
    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
     
  4. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    39
    Trophy Points:
    28
    very true :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice