Factorial of a number program in C

C program to find factorial of a number. It is a simple calculation of a factorial method. This is a basic C tutorial for beginners. Sample source code for this program is given below,

FACTORIAL IN C PROGRAM

This C program is used to find the factorial series for “n” numbers. For example if the factorial is 3, then the calculation will be like this (3! = 3x2x1=6). It will calculate every values by using the looping statement of for loop (for(cn=num;cn>1;cn–)).

FACTORIAL CODE IN C:

Q: Write a C program to calculate factorial of a number.

/* Title: Simple factorial program in c
Author: Vinoth Selvaraj
© http://students3k.com
*/
//Header files
# include <stdio.h>
# include <conio.h>

void main()
{
	//Program variables
	int cn,num,f=1;

	clrscr(); //Function to clear previous output

	printf("Enter the value:"); //Display function
	scanf("%d",&num); //Getting input function

	for(cn=num;cn>1;cn--) //Looping statement
	{
		f = f * cn;
	}
	printf("Factorial of %d is %d",num,f);
	getch();
}