GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO FIND THE FACTORIAL VALUE USING RECURRSION

WRITE A C-PROGRAM TO FIND THE FACTORIAL VALUE USING RECURRSION
AIM:A program to find the factorial value using recurrsion
PROGRAM:
#include<stdio.h>
main()
{
int n,k;
printf("enter the value of n");
scanf("%d",&n);
k=fact(n);
printf("factorial value of a given number :%d",k);
}
fact(int m)
{
if(m==1)
return(1);
else
return(m*fact(m-1));
}
OUTPUT:
enter a number
4
factorial value of a given number: 24
enter a number
3
factorial value of a given number: 6

No comments:

Post a Comment