Skip to main content

Factorial of number using recursion

 #include <stdio.h>

int m;

int fact(int n)

{

    if(n==1||n==0)

    return m=1;

    else

    m=n*fact(n-1);

}

int main()

{

   int n;

   printf("Enter a number to get it,s factorial:-\t");

   scanf("%d",&n);

   fact(n);

   printf("%d",m);

}

Comments

Popular posts from this blog

example of typecasting in c

/*Type Casting in C Typecasting allows us to convert one data type into other. */ //simple example to cast int value into the float. #include <stdio.h>    int   main (){   float   f = ( float ) 9 / 4 ;     printf ( "f : %f \n " ,  f  );     return   0 ;   }