Write a C program to find the factorial of the inputted number
Factorial definition- Factorial is the product of all positive integers less than or equal to n.
It is denoted by – n! .
Write a C program to find the factorial of the number which is being inputted by the user. Below is the solution of the program -
/* Write a C program to find the factorial of that number*/
#include<stdio.h>
void main()
{
int n,i,fact=1;
printf("Enter any number\n");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
fact=fact*i;
}
printf("\n factorial = \t %d",fact);
getch();
}
Input – Enter any number to find the factorial of that number – 5
Output – Factorial of that number is - 120
No comments yet