In C, it is achievable for the functions to alarm themselves. A Function is alleged 'recursive' if a account aural the physique of a action calls the aforementioned function. Sometimes alleged 'circular definition', recursion is appropriately the action of defining something in agreement of itself.

FACTORIAL OF A NUMBER USING RECURSION:


main( )
{
int m, fact ;
printf ( "\nEnter any number " ) ;
scanf ( "%d", &m ) ;
fact = recr ( m ) ;
printf ( "Factorial  = %d", fact ) ;
}
recr ( int a )
{
int z ;
if ( a == 1 )
return ( 1 ) ;
else
z = a * rec ( a - 1 ) ;
return ( z ) ;
}

OUTPUT:

Enter any number 3
Factorial  = 6


0 comments to "RECURSION IN C LANGUAGE"

Post a Comment

Powered by Blogger.