Advance Programs On For LoopLearn C ProgrammingLearn ProgrammingLoop Control StructuresResources

047. Write a program to accept a number from user and print it’s factorial in C language

By September 18, 2012 February 5th, 2018 2 Comments

Eg: factorial of 5 is:-
5! = 5 * 4 * 3 * 2 * 1=120

#include<stdio.h>
#include<conio.h>  
main()
{
	int i,fact=1,n;
	clrscr();
	printf("Enter number...");
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		fact=fact*i;
	printf("facttorialof the given number is...%d",fact);
	getch();

}

2 Comments

Leave a Reply

DEMO01