Function sum takes 2 integers and finds their sum, and assign it to variable total. But main() doesn't have access to this variable, and generally to variables which are defined in other functions. So function main doesn't know their sum yet.

So, to find what the result is, function sum has to return to main this value. So you put the statement "return total;" to say that this function will return the value of "total" to the function which has called it ( in this case, function sum was called from main ).

If you didn't put this statement to function sum, main() wouldn't have the potential to determine the result of x plus y, because, simple, it doesn't have acces to whatever happens to function sum.

But: function sum knows the value of x and y because it got it from main.

the statement "result total;" could be simplier written as "return x + y;" and ommit the use of variable total.

Also, the type of the variable ( double, int, char, float etc. ) which will be returned by a function is the first word which is written in the function prototype.

In this example, because total is of type int, we wrote:

int sum( int, int );