Here is Program which calculates Factorial of a number. For Example 4! =24, 5! =120. See again I have used FOR loop in this program you can also try it with while also to widen your horizons. But soon you realize that FOR loop is the shortest, finest method of programming. Enjoy Programming!!!!!!
/* Program to Calculate Factorial of a Number */
/* Author Mitochondria Technologies Inc. */
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i=1,facto=1;
clrscr();
printf("\n Enter The Number : ");
scanf("%d",&num);
facto=1;
for(i=1;i<=num;i++)
{
facto=i*facto;
}
printf("\n The Factorial of the number entered is : %d",facto);
getch();
}
No comments:
Post a Comment