+ 3

What does return 0; means and where to use it ?

return 0;

6th Sep 2018, 3:39 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
19 Respuestas
+ 1
Usually, zero is returned to the calling function when the program was executed successfully.
6th Sep 2018, 4:16 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
If your function is of type int, then it must always return some value: int main() { // some expression return 0; }
6th Sep 2018, 4:35 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
//This function is not zero: #include <iostream> using namespace std; int timesTwo(int x) { return x*2; } int main() { cout << timesTwo(8) << endl; cout <<timesTwo(5) << endl; cout <<timesTwo(42) << endl; }
6th Sep 2018, 4:51 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
That should return a function of determines the author of the program.
6th Sep 2018, 5:13 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
A function of type "int" ALWAYS returns an integer value. If you do not write "return" the function will still return some value. If you write "return", it will allow you to control this value (what are you waiting for ...) You can use a function like "void" if you do not need a return value from a function
6th Sep 2018, 6:57 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
This means to get desired results it's important to write funcfion type integer. Operator "return" shows only that this function returns. It is important to remember: a function of type integer always returns some value
6th Sep 2018, 7:30 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
In other words, this is the command for the program
6th Sep 2018, 7:40 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
its not something you need to be concerned with, its just ends the program after it has executed
11th Sep 2018, 4:19 AM
Emmanuel Kalu
Emmanuel Kalu - avatar
0
what does this means?
6th Sep 2018, 4:19 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
why 0 not something else ?
6th Sep 2018, 4:44 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
Then what does 0 means and where to use that 0 ?
6th Sep 2018, 5:02 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
Usually return value contains code of error. 0 means that function completes without error.
6th Sep 2018, 5:37 AM
Sergey Ushakov
Sergey Ushakov - avatar
0
this means there is no need to write return 0; or return result; or return a*b*c and so on anywhere?
6th Sep 2018, 6:42 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
this means to get desired results it's important to write return //something
6th Sep 2018, 7:16 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
explain what the operator return actually means?
6th Sep 2018, 7:33 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar
0
some time we have to write return 0; and some time return" variable" ; Please explain this to me?
7th Sep 2018, 2:09 AM
Maitrey Bhaskar
Maitrey Bhaskar - avatar