- Factorial of a non Negative number n is denoted by n!
- Factorial Formula: n! = 1*2*3*4.................*n
- Example: 5! = 5*4*3*2*1
Statement of C program: Input a number and compute its Factorial:
#include<conio.h>
void main()
{
int a,b,c ;
clrscr();
printf("Enter the value of a\n ");
scanf("%d" ,&a);
b=1;
c=1;
while( b<=a )
{
c=c*b;
b++;
}
printf("Factorial=%d\n" , c)
getch();
}
Output1:
Enter the value of a
5
Factorial=120
Output2:
Enter the value of a
7
Factorial=5040
0 Response to "C Program: Find out the Factorial of a Number by using While Statement"
Post a Comment