1#include<stdio.h>
2int main(){
3 int i,f=1,num;
4
5 printf("Enter a number: ");
6 scanf("%d",&num);
7
8 for(i=1;i<=num;i++)
9 f=f*i;
10
11 printf("Factorial of %d is: %d",num,f);
12 return 0;
13}
1//Factorial of a given number
2#include <stdio.h>
3
4//This function returns factorial of the number passed to it
5long int factorialOf(int number){
6 long int factorial = 1;
7 while(number){
8 factorial*=number;
9 number-=1;
10 }
11 return factorial;
12}
13
14int main(void) {
15 int n;
16 printf("Find factorial of \n");
17 scanf("%d",&n);
18 printf("\nThe factorial of %d is %ld",n,factorialOf(n));
19 return 0;
20}