Code -
//__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 = 0, factorial = 1, temp = 0;
//____________Variable Declaration_____________
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();
}
Follow Us on Facebook - Assignment Hub
No comments:
Post a Comment