C program to calculate factorial using for loop
/***********************************************************
C program to calculate factorial using for loop
***********************************************************/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,fact=1;
clrscr();
printf("** OUTPUT**\n");
printf("Enter number to calculate factorial\n");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
fact=fact*i;
}
printf("The factorial of %d is %d\n",num,fact);
printf("End of program");
}
** OUTPUT**
Enter number to calculate factorial
5
The factorial of 5 is 120
End of program
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏