Silly little fact

This is a discussion on Silly little fact within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Did you know that the "hello world" program can be written in countless ways? Here are a few: Code: #include ...

  1. #1
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176

    Post Silly little fact

    Did you know that the "hello world" program can be written in countless ways? Here are a few:
    Code:
    #include <iostream.h>
    int main()
    {
    cout<<"Hello, world!";
    return 0;
    }
    Code:
    #include <iostream.h>int main(){cout<<"Hello, world!";return 0;}
    Code:
    #include 
    <iostream.h>
    int
    main()
    {
    cout<<
    "Hello, world!";
    return
    0;
    }
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  2. #2
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Oh Yeah, acctually they are all the same, since the compiler locataes the semicolons to indicate the end of a statement, so new lines won't matter in a code like this...
    none...

  3. #3
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    We just use it like the first one for readible code.
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    That's true about anything in C++. In general, lines and spaces don't mean much -- it's semicolons and braces that really matter.

  5. #5
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i think this is more a GD topic less u be having trouble with the code....

  6. #6
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Wow, you weren't kidding when you said this fact was silly and little.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  7. #7
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    I think there was a typo and Fuh meant to put "pointless little fact".

    Yes, but it can even be written in more ways than that...

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
     {
       cout << "Hello World";   
       return 0;
     }
    Code:
    #include <iostream>
    
    int main()
     {
       std::cout << "Hello World";
       return 0;
     }
    And actually my ways are the proper C++ ways hehe. Then again it's not like that my ways are anything new to anyone so yeah I'm still not special.

  8. #8
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Amazing, fuh, incredibly amazing. We're all newbies like you when it comes to programming, aren't we?

    Code:
    extern "C"
    {
    	system(const char*);
    }
    
    void main()
    {
    	system("echo Hello World!");
    }
    Last edited by abrege; 12-31-2002 at 05:26 PM.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    Quite a few more.
    Joe

  10. #10
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
      int i = 0;
      char string[] = "Hello, world!";
      while(i < strlen(string) + 1)
      {
       printf(" ");
       i++;
      }
      for(i = strlen(string)-1; i > -1; i--)
      {
       printf("\b\b");
       printf("%c",string[i]);
      }	
      return 0;
    }

  11. #11
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Originally posted by JoeSixpack
    Quite a few more.
    Heh, heh, that was funny. I especially like this one.

    I was actually a little worried if that was real until I got to the bottom of the page.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  12. #12
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    905
    Erm, how does "Fuh" get pronounced (Foo - Ha)?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  13. #13
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Originally posted by JoeSixpack
    Quite a few more.
    I like this link, very funny...
    none...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Silly Jokes
    By Snafuist in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 03-02-2009, 06:40 PM
  2. Silly Q about circular references
    By ppmoore in forum C Programming
    Replies: 8
    Last Post: 10-04-2006, 02:07 PM
  3. best download site
    By gooddevil in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-20-2004, 10:36 PM
  4. Sreen Resolution Statistics?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 04-26-2004, 02:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21