codescracker


c

C Program to Find Factorial of Number



« Previous Program Next Program »


Find Factorial of Number in C

To find the factorial of a number in C programming, you have to ask to the user to enter the number. Now find factorial of the number using the for loop and display the factorial result of the number

C Programming Code to Find Factorial of Number

Following C program ask to the user to enter a number to find its factorial, then display the result on the screen :

C Programming Example Souce Code:
/* C Program - Find Factorial of Number */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int num, i, fact=1;
	printf("Enter a number : ");
	scanf("%d",&num);
	for(i=num; i>0; i--)
	{
		fact=fact*i;
	}
	printf("Factorial of %d is %d",num,fact);
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program find factorial of number

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test