write a program that finds the factorial of a number using
recursion?
Answer Posted / meenakshi
#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 ? | 17 Yes | 8 No |
Post New Answer View All Answers
In a switch statement, explain what will happen if a break statement is omitted?
what are bit fields? What is the use of bit fields in a structure declaration?
What is wild pointer in c?
what are the 10 different models of writing an addition program in C language?
Can you write the algorithm for Queue?
What is call by reference in functions?
What is the purpose of type declarations?
What is a ternary operator in c?
shorting algorithmS
which is conditional construct a) if statement b) switch statement c) while/for d) goto
What is pointer to pointer in c language?
What are the advantages of union?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Tell me about low level programming languages.
What is sizeof in c?