I dont believe there is a differnce between 0 and (0), but i'm not sure.
When a program is executed correctly, it returns the value 0. Then the user or the program interacting with this program knows that there hasn't been problems while executing the program.
When the program returns another value as 0, eg 1 or 2, it means someting unexpected happend. The computer keeps doing what he needs to do, so you could use it without see anny effect of it.
1. Extra typing (two parentheses), otherwise absolutely nothing.
2. Every process returns a return code to its parent. The value that is returned
to the parent is the return value from main. main() by standard returns int
which means you can return any integer value you want (returning 0 typically
means success and non-zero is some application-specific error code)
although I believe some OSes only handle 8-bit return codes, so you should
probably only return values 0-255.
thanks to all the repliers especially jsmith.
The thing that i have understood is that when a parentheses is used , the value inside the parentheses is to be returned to the calling statement .
But if a parentheses is not used then the code can be interpreted as , the program has been executed without returning any errors .
hence a proper way of writing is return 0; instead of writing 1 or 2 in place of 0.
i hope i have understood it correctly.
Part of your statement does not sound right to me.
The "return" keyword is used to return a value from a function back to the calling statement. The syntax "return expr;" tells the compiler to evaluate the mathematical expression denoted by "expr" and return that result back to the caller. The syntax "return ( expr );" does the exact same thing.
Parentheses around expressions in C/C++ are used only to clarify/denote precedence of operations. eg, the expression 2 + 3 * 4 yields 14 since multiplication has higher precedence than addition, but the expression ( 2 + 3 ) * 4 yields 20 since the parentheses tell the compiler that it should be the sum of 2 and 3 that should be multiplied by 4 (hence the compiler must generate code to add 2 and 3 before multiplying by 4).