The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.
When a programmer wants other than integer values to be returned from function then it is essential that the programmer follows the steps provided here below:
1. Mention the return type in the calling function
2. Mention the return type in the called function.
Both steps 1 and 2 must be made if the return value is other than integer.
Let us see how to do this with a example:
z1= x1+ y1
Here the output would be
Here the return value is float from function sample. Therefore as said before it is declared in calling function namely main() as
after the variable declaration in main() and it is also declared in the function sample as
It is vital for programmers to follow the above method to get correct return value from function.