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
What are the restrictions of a modulus operator?
how to count no of words,characters,lines in a paragraph.
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
What are the valid places to have keyword “break”?
code for find determinent of amatrix
Is boolean a datatype in c?
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
Under what circumstances does a name clash occur?
What is function prototype in c with example?
Which is better oop or procedural?
Can you please explain the difference between syntax vs logical error?
What is #include called?
Explain what are the standard predefined macros?
How do you determine a file’s attributes?
Which driver is a pure java driver