main( )
{
int m, f ;
printf ( "\nEnter number " ) ;
scanf ( "%d", &m ) ;
f = factorial ( m ) ;
printf ( "Factorial = %d", f ) ;
}
factorial ( int a )
{
int fact = 1, j ;
for ( j = a ; j >= 1 ; j-- )
fact = fact * j ;
return ( fact ) ;
}

OUTPUT:

Enter number 4
Factorial = 24


0 comments to "FACTORIAL OF A NUMBER WITHOUT RECURSION IN C"

Post a Comment

Powered by Blogger.