write a program that finds the factorial of a number using
recursion?
Answer Posted / inderjeet
#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 ? | 62 Yes | 18 No |
Post New Answer View All Answers
What is dynamic dispatch in c++?
Does c have enums?
What is the acronym for ansi?
What are the types of assignment statements?
Why does notstrcat(string, "!");Work?
2) Write a program that will help Air Traffic Control for an airport to view the sequence of flights ready for take-off. The airport can accommodate 10 flights waiting for take-off at any point in time. Each flight has a unique 3 digit numeric identifier. Each time a flight takes-off, Air Traffic Control adds a flight to the waitlist. Each time a flight is added to the waitlist, the list of flights waiting to take-off must be displayed. When a flight is cleared for take-off, Air Traffic Control removes the flight from the waitlist. Each time a flight takes-off, the list of flights waiting to take-off must be displayed. Sequence of take-off is the sequence of addition to the waitlist
Why c is faster than c++?
how to write a c program to print list of fruits in alpabetical order?
Why functions are used in c?
Where is volatile variable stored?
Can a variable be both constant and volatile?
What are formal parameters?
What is the explanation for cyclic nature of data types in c?
What are structures and unions? State differencves between them.
what is the diffrenet bettwen HTTP and internet protocol