Friday, July 31, 2009

Factorial

//Program made by Puneet Sharma
#include
#include
//To calculate factorial of a no
int factorial (int i )
{
if (i==1)return 1 ;
else return( i* factorial(i-1)) ;
}
int sumdigit(int i )
{
if (i<=0) return 0 ; else return( i%10 + sumdigit(i/10) ) ; } void main() { printf("\n%d " , factorial(5) ) ; printf("\n%d " , sumdigit(31564) ) ; getch(); }

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.