write a program that finds the factorial of a number using
recursion?

Answer Posted / anandi

#include<stdio.h>
#include<conio.h>
void main()
{
int factorial(int);
int n;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
getch();
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}

Is This Answer Correct ?    197 Yes 32 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is const keyword in c?

753


What is string constants?

664


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

653


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

1586


what are # pragma staments?

1634






Where local variables are stored in c?

562


How can I manipulate strings of multibyte characters?

643


What is the use of static variable in c?

599


How do we make a global variable accessible across files? Explain the extern keyword?

1428


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜nā€™ element.

1587


What is auto keyword in c?

792


What is a dynamic array in c?

601


How to write c functions that modify head pointer of a linked list?

548


Define VARIABLE?

692


Which node is more powerful and can handle local information processing or graphics processing?

831