#include <iostream> using namespace std; int main() { cout << "Hello world!"; return 9; } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

#include <iostream> using namespace std; int main() { cout << "Hello world!"; return 9; }

in c++ the out put is the same as return 0; why??

2nd Nov 2018, 6:51 AM
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲ - avatar
6 Answers
+ 4
It's just by definition that 0 means "everything ok". If people had agreed on "1 means everything ok", then it would be return 1; But they decided on 0
2nd Nov 2018, 10:23 AM
Matthias
Matthias - avatar
2nd Nov 2018, 9:03 AM
KrOW
KrOW - avatar
+ 2
That output is for the OS. It can be used in batch jobs
2nd Nov 2018, 7:07 AM
Микола Федосєєв
Микола Федосєєв - avatar
+ 2
If it returns 0, it means everything went fine. Other values mean different error codes, to tell what went wrong in the programm, even when it hit the end.
2nd Nov 2018, 8:52 AM
Matthias
Matthias - avatar
+ 1
so what is the purpose to use the 0 here is my question?
2nd Nov 2018, 10:13 AM
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲ - avatar
+ 1
Matthias, i got you; Thank you!
2nd Nov 2018, 4:55 PM
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲
D ̲E ̲S ̲S ̲I ̲E ̲- ̲B ̲A ̲H ̲I ̲R ̲U ̲ - avatar