Code Scrappers


Factorial C program


              #include<stdio.h>
              #include<stdlib.h>

              int fact(int);

              int main()
              {
                  int factorial, number;

                  printf("Enter the number :");

                  scanf("%d", &number);

                  factorial = fact(number);

                  printf("Factorial of %d is %d",number,factorial);

                  return (0);
              }

              int fact(int n)
              {
                  if (n == 0)
                  {

                      return (1);

                  }

                 return (n * fact(n - 1));
              }


          



Output

    Enter the number :4
    Factorial of 4 is 24