anita_86 — 2012-01-04T07:32:19-05:00 — #1
Hi again!And happy new year to all.Just got to attained an interview and was asked about some c questions.I am not sure I am posting in right forum, but would like to know what does these lines means?Can anyone tell me?
parkint — 2012-01-04T07:44:54-05:00 — #2
That is C language.
It would compile into a very small program that outputs "Hello" (without the quotes).
The last line is NOT part of the program and would throw a compiler error. It appears to be a reference to the output (e.g. O/P)
All C programs require an "entry point" and the default is called main (which always returns a result code as an integer.
The routine is enclosed in curly braces. The statement 'printf' is a formatted print function that is part of [one of] the native libraries in C
Here is an overview reference about the language.
molona — 2012-01-04T07:46:19-05:00 — #3
If you do a google search you can find it yourself...
You're outputting "Hello" on the screen but since the function main has to return an integer (you said that when you named the function "int main()") you return 0 (meaning that the function has succeed)
But if the function doesn't work, the exit function will end it up and return a code error 10
I'm more than happy to help but sometimes I wish that people would use Google a bit.
Edit: Seems that ParkinT was quicker than me
anita_86 — 2012-01-04T08:02:50-05:00 — #4
Ok I got it a little bit.Thanks for quick reply.Going line by line, int main() is a function which is integer.And if it returns error, it returns error code 10 and exits the function.Since the functions dosent work,it is returning 0.Im I right?
molona — 2012-01-04T08:42:10-05:00 — #5
Almost there but...No
If the function main works perfectly, it will print the message on screen and the value returned will be 0.
If there's an error, the value returned will be 10.
parkint — 2012-01-04T14:06:47-05:00 — #6
I agree and would much rather see a question posed as, "I searched for the answer, found this, but would like a little more clarification from someone with direct experience in this area"
This is a very helpful community, but there is A LOT to be gained from [even an attempt at] seeking the answer on your own first.
anita_86 — 2012-01-04T23:31:56-05:00 — #7
Thanks a lot.and the link is very useful.
Thats very true.and I will keep it in mind next time