C programming
int main()
{
int n, fact = 1;
printf("Enter a number :\n");
scanf("%d", &n);
for (int i = 1; i<= n; i++)
fact = fact * i;
printf("Factorial of %d = %d\n", n, fact);
return 0;
}
Try it Yourself ➠
factorial of a number in C
26 July
0
Write a program (WAP) in C to calculate factorial of a number.
#include <stdio.h>int main()
{
int n, fact = 1;
printf("Enter a number :\n");
scanf("%d", &n);
for (int i = 1; i<= n; i++)
fact = fact * i;
printf("Factorial of %d = %d\n", n, fact);
return 0;
}
Must Read :-
Previous article
Next article
Leave Comments
Post a Comment