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:

1 Ans Write a C program to find the highest and lowest number in a series

1 Ans How to Learn HTML - HyperText Markup Language easily? 

1 Ans Write a C++ program for BigMod math

3 Ans Three ways to find Greatest Common Divisor (GCD) and Least Common Multiple (LCM) in a C program

1 Ans Best Web development site in the internet ?

1 Ans Single Digit Interest Rate in the Banking Sector: Problems and Prospects - essay writing

1 Ans The general rules for constructing names for variables (unique identifiers)

1 Ans A Quest for Peace in the Middle East: Recent Perspectives - composition

1 Ans Which is the best and easy C programming learning website ?

1 Ans Write a C program to check a Prime number