#include <stdio.h>
// Function to calculate factorial
int factorial(int num) {
int fact = 1; // Initialize the factorial variable to 1
// Iterate from 1 to num and multiply each number to calculate factorial
for (int i = 1; i <= num; i++) {
fact *= i;
}
return fact; // Return the calculated factorial
}
int main() {
int num; // Declare a variable to store user input
printf(""); // Prompt the user to enter a number
scanf("%d", &num); // Read the input number from the user
// Calculate factorial by calling the factorial function
int result = factorial(num);
// Output the result
printf("The factorial of the given number is: %d\n", result);
return 0; // Indicate successful termination of the program
}
int main() {
int num;
int fact = 1;
scanf(“%d”, &num);
for(int a = 1; a <= num; a = a + 1)
{
fact = fact*a;
}
printf(“The factorial of the given number is: %d \n”,fact);
return 0;
}