+ 2
What is the purpose of returning in a function?
I don't understand. There are example programs that return 0 or nothing, is that necessary? I am asking because the program still seems to work fine, even if I remove that line.
3 Answers
+ 4
return 0 in main signifies that the program executed correctly. in modern compilers, it can be omitted
+ 1
If the function declaration returns a type other than "void", the "return" statement is mandatory. The compiler will warn you if you omitted this or can return automatically the initial value of the corresponding data type (only for implicit data types like int, float, string, etc.).
0
firstly you need to know that there are two types of functions impure and pure.pure has datatype as return type and impure has void has return type and in last line of pure you need to return a value with a datatype similar to as you have declared in function header.