Ask Question - Get Answer

1 Ans Write a C Program to find factorial using recursion

Asked by AL MaMun (4 Golds) Friday, 31 Jul 2020, 04:12 PM at (Education Tutorials)

Please log in to answer, like and save
0
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

A C program to find factorial using recursion.


#include<stdio.h>

int factorial(int n)

{

    if(n==0)

        return 1;

    else

        return n*factorial(n-1);

}

int main()

{

    int n, result;

    printf("Enter a positive integer: \n");

    scanf("%d", &n);

    if(n>=0)

    {

        result=factorial(n);

        printf("Factorial = %d", result);

    }

    else

        printf("Please Enter a positive Integer! ");

    return 0;

}


Answered by AL MaMun (4 Golds) Friday, 31 Jul 2020, 04:13 PM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

2 Ans BPSC Programming Aptitude Lab Test Important programs

1 Ans Write a C program for Interest Calculation

1 Ans Write a C program to check a perfect number

2 Ans Write a C program to implement Selection sort data structure and algorithm

1 Ans Write a C program to print Floyd Triangle

1 Ans Best Web development site in the internet ?

1 Ans Write a C program to check a Prime number

1 Ans A C Program to split a number into digits

1 Ans Write a C program to find nth Fibonacci number

1 Ans Write a C program to check a Palindrome Number