Program will calculate the factorial of a given number (No Validation included)
//____________________Include Header Files_________________
#include<stdio.h> //________Header Files are also known as Preprocessor directives____________
#include<conio.h> //________Mainly for the getch function included in program_________________
int main() //___________This is from where the execution starts_____________________
{
int number, factorial, temp; //____________Variable Declaration_____________
factorial = 1; //___________Initializing the number to 1 which will store the factorial of a given number__________
printf("\n\t\t\t_______Factorial of a Number_______");
printf("\n\n\t Enter the Number - "); //____________Prompting the user to enter the number for which to calculate
scanf("%d", &number); //_________Reading the user input and storing the input in variable number_________
for(temp = number ; temp >= 1; temp --)
{
factorial = factorial * temp;
}
printf("\n\n\t Factorial of %d is - %d",number,factorial); //_______Display the final output_________
getch();
}
OUTPUT
Composed By:-Assignment-Hub
Posted By:-Cplusplusprogramming
//____________________Include Header Files_________________
#include<stdio.h> //________Header Files are also known as Preprocessor directives____________
#include<conio.h> //________Mainly for the getch function included in program_________________
int main() //___________This is from where the execution starts_____________________
{
int number, factorial, temp; //____________Variable Declaration_____________
factorial = 1; //___________Initializing the number to 1 which will store the factorial of a given number__________
printf("\n\t\t\t_______Factorial of a Number_______");
printf("\n\n\t Enter the Number - "); //____________Prompting the user to enter the number for which to calculate
scanf("%d", &number); //_________Reading the user input and storing the input in variable number_________
for(temp = number ; temp >= 1; temp --)
{
factorial = factorial * temp;
}
printf("\n\n\t Factorial of %d is - %d",number,factorial); //_______Display the final output_________
getch();
}
OUTPUT

Composed By:-Assignment-Hub
Posted By:-Cplusplusprogramming