Knowledge of Engineering
This site encapsulates the tips you require to be successful in engineering.
Pages
Home
Computer Programming Old Questions IOE
Object Oriented Programmming in C++
Electrical Machine Design
Artificial Neural Network (ANN)
Old Questions Institute of Engineering (IOE), TU
Monday, December 13, 2010
Program to find the factorial of a number using recursive function
#include<stdio.h>
int factorial(int);
int main()
{
int n;
printf("Enter the number:");
scanf("%d",&n);
printf("The factorial is %d",factorial(n));
return 0;
}
int factorial(int n)
{
if(n<=1)
{
return 1;
}
else
{
return n*factorial(n-1);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment