PPS Practical 46

PPS Practical 46
  • Aim: Write a program to find factorial of a number using recursion.
  • Code:
    //For turbo C++ remove below comments
    #include <stdio.h>
    //#include<conio.h>
    int fact(int n){
        if (n==1){
            return 1;
        }
        return n*fact(n-1);
    }
    void main()
    {
        int n;
        //clrscr();
        printf("Enter Number : ");
        scanf("%d",&n);
        printf("Factorial of %d is : %d",n,fact(n));
        // getch();
    }
  • Output:
    Output of practical 46

Comments