1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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,276
    Likes Received:
    364
    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:
    7
    Trophy Points:
    0
    How much twist can be impared with just Hello World
     
  3. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    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:
    734
    Likes Received:
    37
    Trophy Points:
    0
    very true :)
     

Share This Page