#include <stdio.h>
int getData(){
int n;
printf("\nEnter a number: ");
scanf("%d",&n);
return n;
}
void factorial(){
int x=getData();
int fact=1;
if (x==1)
printf("\nFactorial of %d = 1",x);
else{
for(int i=1;i<=x;i++){
fact=fact*i;
}
printf("\nFactorial of %d = %d",x,fact);
}
}
int main()
{
factorial();
return 0;
}
Comments
Leave a comment