Here's this program..could someone explain me where the function (mystery) is declared? i mean where is say that mystery returns a*b???
Code:
#include <stdio.h>
#include <stdlib.h>
int mystery( int a, int b ); /*function prototype*/
/*function main begins program execution*/
int main()
{
int x;/*first integer*/
int y;/*second integer*/
printf("Enter two integers: ");
scanf("%d %d", &x, &y);
printf("The result is %d\n", mystery(x,y));
system("pause");
return 0; /*indicates succesful termination*/
} /*end main*/
/*Parameter b must be a positive integer
to prevent infinite recursion */
int mystery( int a, int b )
{
if ( b==1 )
{
return a;
}
else /*recursive step*/
{
return a + mystery( a, b-1 );
}
}/*end function mystery*/
Thanks in advance!