FACTORIAL NUMBERS USING C



To write a c program to find the factorial of given number using recursion.



/*FACTORIAL NUMBERS*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,res;
clrscr();
int factorial(int);
printf("Enter number:");
scanf("%d",&n);
res=factorial(n);
printf("result is:%d",res);
getch();
}
int factorial(int n)
{
int fact;
if(n==0)
return(1);
else
fact=n*factorial(n-1);
return(fact);
}





OUTPUT:
            FACTORIAL NUMBER
Enter number:3

result is:6
 


Comments

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE