#include
main()
{
printf("hello world!");
}
//output is
//hello world!
Quite simple?
But I think it is not at all simple. The special characters present in the program really offer some disturbances for the beginner, however a C program is not redundant and it is extreamly powerful.
In Python, I found a much more convenient way.
print "hello world!"
Simple?
It seems good but there is still void to shrink.
Take a look at Ruby,
"hello world"
That's it. I didn't found any void to shrink here. Just put the string you want to print in quotes (" ") and it is pretty easy. But this is not the standard way of printing a string on the monitor, as far as the offcial website of Ruby is concerned. They recommends,
puts ("hello world!)
Then the output will be,
Hello World
=> nilnil stands for there is nothing to return.
4 comments:
You have already said that just 'hello world!' is not a valid method. Then what's the difference between ruby and python?
Dude, All scripting languages can have single line 'hello world'.
Then what's the difference between ruby and python?
Reply:
Mr. Anonymous, I accept your argument. All scripting language has a single line hello world. But they can't shrink their line to as small as 'hello world!'. Just look this python code:
>>>def x():
... print "Hello World!"
>>>x() #Really small isn't it?
Hello World!
this / Puts / can also be used in C....
Reply to Saju John
Yes, almost all programming languages copied something from C I think.
Post a Comment