Sunday, 15 March 2015

Program to find the factorial of a given number Using C

# include <stdio.h>
# include <conio.h>

void main()
{
long n, i, f = 1 ;
clrscr() ;
printf("Enter a number : ") ;
scanf("%ld", &n) ;
for(i = 1 ; i <= n ; i++)
f = f * i ;
printf("\nFactorial value of %ld is : %ld", n, f) ;
getch() ;
}

RUN 1 :
~~~~~~~
Enter a number : 5
Factorial value of 5 is : 120

No comments:

Post a Comment