Before I continue on with my lessons in C, I want to make sure I understand the use of the Return statement within my own functions. From what I understand, when the program encounters the Return statement within function it immediatly returns to the function that called it? or does it return to main()? Also from the examples I've seen, something like Return( 1 + 4 ); would return the value "5" to the Function name the Return statement was part of? Therefore, you can use a Function name within a printf statement to display a value? So that means a function can be used to same as any variable I'm assuming?
Is my logic correct on this? And would the program below work (and make sense)?
Code:#include <stdio.h> int AddNumbers ( int x, int y ); int main ( ) { printf( "My returned value is: %d\n", AddNumbers( ) ); // calls the function and a value is returned to it return 0; } int AddNumbers ( int x, int y ) { x = 1; y = 4; return( x + y ); }