0

What is return value and what is its use?

4th Sep 2016, 9:22 AM
ANKUR POWAR
2 Antworten
+ 1
AnKuR, from a mathematical perspective on functions, the return value is the result the function calculates. In programming these return values can be empty (see "void"). If a return value is empty, the function is either empty or it has only side effects (no modification of parameters, but e.g. console output, modification of a global variable or memory that is not parameters in general). Oftentimes, the return value is determined by convention. The main function is a good example: returning 0 means "no error occurred in the program", all other (positive) values are codes to signal the kind of error that occured.
4th Sep 2016, 10:36 AM
Stefan
Stefan - avatar
0
main() returns an int type to operating system.therefore, evry main() shud end with a return(0) statement; otherwise a warning or an error might occur.note that default return type for all functions in c++ us int. hope now u ll understand the concept of return.
4th Sep 2016, 9:55 AM
Shivesh Karan Mehta
Shivesh Karan Mehta - avatar