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

Answer Posted / bala c king

#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 ?    35 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the restrictions of a modulus operator?

638


how to count no of words,characters,lines in a paragraph.

3907


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3249


What are the valid places to have keyword “break”?

651


code for find determinent of amatrix

1519






Is boolean a datatype in c?

547


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

665


Under what circumstances does a name clash occur?

692


What is function prototype in c with example?

580


Which is better oop or procedural?

634


Can you please explain the difference between syntax vs logical error?

697


What is #include called?

568


Explain what are the standard predefined macros?

653


How do you determine a file’s attributes?

602


Which driver is a pure java driver

993