Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

Can someone explain me why we put return 0?

OpenStudy (anonymous):

And also where we put that?

OpenStudy (anonymous):

programs return 0 when they exit to let the OS know that it has terminated successfully and nothing has gone wrong. something like "return 0" should exist somewhere within the main function of your C/C++ program

OpenStudy (anonymous):

we also put system 'pause' right. then y is that

OpenStudy (anonymous):

system("pause"); is not really needed; it's used because when you run it on windows, the "cmd" window opens/closes really fast.

OpenStudy (anonymous):

in some codings where we use sub functions we put return name, return regno etc. y is that?

OpenStudy (anonymous):

we do that because it's how we program; we compose our programs from these subroutines/procedures that return a value or change state.

OpenStudy (anonymous):

OpenStudy (anonymous):

Pls see the attachment.

OpenStudy (anonymous):

you do get similar output in both programs, with slight differences in the way the functions work (second one has string exist in one frame, etc.).

OpenStudy (anonymous):

If u dnt mind cn u tel me in which case u use 1st one and which case u use the second.

OpenStudy (anonymous):

With the first one, you can reuse the display() function if you ever want to get string input from the user. With the second one, you use it if you want to reuse the ability to have the user enter a string, and then echo it as "Name is\t" + hisname

OpenStudy (anonymous):

sorry I dnt get t.

OpenStudy (anonymous):

What I can do if I used version 2: http://ideone.com/AKT0r contrast with what i can do with version 1 http://ideone.com/AXfKR

OpenStudy (anonymous):

Thanx a lot for ur great help.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!