- Program :
#include <stdio.h>
int main()
{
int n, i;
unsigned long long fact = 1;
printf("\n----------------FACTORIAL OF NUMBERS----------------");
printf("\nEnter an integer: ");
scanf("%d", &n);
if(n<0)
printf("\nError! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("\nFactorial of %d = %llu", n, fact);
}
return 0;
}
- Output :
No comments:
Post a Comment