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 for BigMod math

1 Ans Write a C program to print Fibonacci number using recursion

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

3 Ans BPSC Assistant Programmer Lab Aptitude test Programs and Queries with Proper solution (Taken By BCC)

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

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

1 Ans Write a C Program to check Anagrams of two strings

2 Ans Write a C program for Binary Search algorithm

2 Ans Train Location Message TR Train_Code and Send to 16318 Example: TR 705 Send to 16318

1 Ans Best Web development site in the internet ?