C Program to Find Factorial of n using For Loop
Write a Program to Find Factorial of n using For Loop
// C Program to Find Factorial of n using For Loop
#include <stdio.h>
int main()
{
int n, i, fact = 1;
printf("Enter the number :--> ");
scanf("%d", &n);
for(i = 1; i<=n; i++)
{
fact = fact * i;
}
printf("The factorial of %d is %d\n", n, fact);
return 0;
}
Output:
Enter the number :--> 6
The factorial of 6 is 720