Write about Nesting of Functions?
https://www.computersprofessor.com/2016/12/write-about-nesting-of-functions.html?m=0
C performs nesting of functions freely main can call function 1, which call function 2; which calls function 3,……….. And so on.
Syntax :
main ( )
{
…….
…….
fn 1( );
}
float fn1( )
{
……..
……..
fn 2( );
}
int fn2( )
{
……
.…..
}
Ex:
float ratio ( int x, int y, int z);
int diff ( int x, int y);
main ( )
{
int a, b, c;
scanf (“%d%d%d”, & a&b&c);
printf (“%f \n “, ratio (a,b,c));
}
float ratio ( int x, int y, int z)
{
if ( diff (y,z))
return ( x/(y-z));
else
return ( 0,0);
}
int diff ( int p, int q)
{
if ( p! = q)
return ( 1);
else
return ( 0);
}
Nesting of function calls is also possible.
Ex: P = mul ( mul (5,2),6);
The inner function call is evaluated first and the returned value is again used as an actual argument in the outer function call.