Below is the program to find the factorial of a given number
#include <stdio.h>
int main(){
int n,fact=1,i;
printf("Enter a number:");
scanf("%d",&n);
if(n<0){
printf("Factorial of negative number doesn't exist");
}else{
for(i=1;i<=n;i++){
fact*=i;
}
printf("Factorial of given number is %d",fact);
}
}
Output:
Enter a number:6
Factorial of given number is 720