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


Please Help Members By Posting Answers For Below Questions

What is dynamic dispatch in c++?

558


Does c have enums?

602


What is the acronym for ansi?

631


What are the types of assignment statements?

630


Why does notstrcat(string, "!");Work?

643






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

2521


Why c is faster than c++?

633


how to write a c program to print list of fruits in alpabetical order?

1791


Why functions are used in c?

587


Where is volatile variable stored?

650


Can a variable be both constant and volatile?

562


What are formal parameters?

660


What is the explanation for cyclic nature of data types in c?

648


What are structures and unions? State differencves between them.

619


what is the diffrenet bettwen HTTP and internet protocol

1392