What is return 0; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is return 0;

what is return 0; in c++ programming . what is its use

20th Apr 2018, 8:38 AM
chandrapal singh
chandrapal singh - avatar
11 Answers
+ 2
A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void.
20th Apr 2018, 8:46 AM
Ayush Bious Raj
Ayush Bious Raj - avatar
+ 2
You an also ommit return 0; at the end of your main function and it gets generated automatically.
20th Apr 2018, 8:49 AM
Timon Paßlick
20th Apr 2018, 8:52 AM
Timon Paßlick
+ 2
chandrapal singh What I wrote: It will be generated automatically.
20th Apr 2018, 8:53 AM
Timon Paßlick
+ 1
You can use any number but 0 is used for tell to calling system eventual that execution was go ok with no errors (you can run a process by another process and wait for result)
20th Apr 2018, 8:47 AM
KrOW
KrOW - avatar
+ 1
means
20th Apr 2018, 8:53 AM
chandrapal singh
chandrapal singh - avatar
+ 1
chandrapal singh Your code will work as if you had written return 0; at the end of your main function.
20th Apr 2018, 8:54 AM
Timon Paßlick
0
bhai app India se ho
20th Apr 2018, 8:48 AM
chandrapal singh
chandrapal singh - avatar
0
if i don't write return0
20th Apr 2018, 8:50 AM
chandrapal singh
chandrapal singh - avatar
0
then what will happen
20th Apr 2018, 8:52 AM
chandrapal singh
chandrapal singh - avatar
0
In the main function it’s the “conventional” return code to the caller from an application which exited with no error. You can change this value at will, for example return 9 if you can’t read a file, return 5 if your app couldn’t connect to a database, etc..
20th Apr 2018, 9:06 AM
Luigi
Luigi - avatar