int f1(int a, int b) { return ( f2(20) ); } int f2(int a) { return (a*a); }
Example:
#include <stdio.h>
int f1(int, int); /* Function prototype */
int f2(int); /* Function prototype */
int main()
{
int a = 2, b = 3, c;
c = f1(a, b);
printf("c = %d\n", c);
return 0;
}
int f1(int a, int b)
{
return ( f2(20) );
}
int f2(int a)
{
return (a * a);
}
Output:
c = 400
Example:
#include <stdio.h>
int mul(int, int); /* Function prototype */
int main()
{
int a = 0, b = 3, c;
c = mul(a, b);
printf("c = %d\n", c);
return 0;
}
/* Two return statements in the mul() function */
int mul(int a, int b)
{
if(a == 0 || b == 0)
{
return 0;
}
else
{
return (a * b);
}
}
Output:
c = 0
In a loop, there is no recursive call involved that saves a lot of time and space too.
After sometime the stack memory will be filled completely. Hence stack overflow error will occur.
Copyright ©CuriousTab. All rights reserved.