PDA

View Full Version : Silly little fact



fuh
12-31-2002, 03:18 PM
Did you know that the "hello world" program can be written in countless ways? Here are a few:

#include <iostream.h>
int main()
{
cout<<"Hello, world!";
return 0;
}
#include <iostream.h>int main(){cout<<"Hello, world!";return 0;}
#include
<iostream.h>
int
main()
{
cout<<
"Hello, world!";
return
0;
}

ammar
12-31-2002, 03:22 PM
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...

fuh
12-31-2002, 03:27 PM
We just use it like the first one for readible code.

Polymorphic OOP
12-31-2002, 04:54 PM
That's true about anything in C++. In general, lines and spaces don't mean much -- it's semicolons and braces that really matter.

RoD
12-31-2002, 05:00 PM
i think this is more a GD topic less u be having trouble with the code....

joshdick
12-31-2002, 05:12 PM
Wow, you weren't kidding when you said this fact was silly and little.

TechWins
12-31-2002, 06:04 PM
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...



#include <iostream>

using namespace std;

int main()
{
cout << "Hello World";
return 0;
}




#include <iostream>

int main()
{
std::cout << "Hello World";
return 0;
}


And actually my ways are the proper C++ ways hehe.:D Then again it's not like that my ways are anything new to anyone so yeah I'm still not special.:o

abrege
12-31-2002, 06:19 PM
Amazing, fuh, incredibly amazing. We're all newbies like you when it comes to programming, aren't we?



extern "C"
{
system(const char*);
}

void main()
{
system("echo Hello World!");
}

JoeSixpack
12-31-2002, 07:08 PM
Quite a few more (http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html).

Brian
12-31-2002, 07:38 PM
#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;
}

joshdick
01-01-2003, 02:00 AM
Originally posted by JoeSixpack
Quite a few more (http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html).
Heh, heh, that was funny. I especially like this one (http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html).

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

CodeMonkey
01-01-2003, 02:08 AM
Erm, how does "Fuh" get pronounced (Foo - Ha)?

ammar
01-01-2003, 08:01 AM
Originally posted by JoeSixpack
Quite a few more (http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html).
I like this link, very funny...