Program of Factorial - Write a program of factorial in C Language - Factorial Program - Factorial Program Kaise Banaye
Program of Factorial in C Language
#include <stdio.h>
int main() {
int n, i, fact = 1;
printf("Enter an integer: ");
scanf ("%d", &n);
if (n < 0)
printf("Please enter number which is more than 1.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %d", n, fact);
}
return 0;
}
Program In the Code Block IDE
In Code Block IDE you can type the above program or just copy it from here and paste it in the coding place like we did in the given screenshot
After that, you can save it and run the program
Comments
Post a Comment