Showing posts with label fro. Show all posts
Showing posts with label fro. Show all posts

Monday, February 21, 2011

Factorial Program!!

This program computes the factorial of the given number and displays it. The control structure 'for' is used to determine the factorial. When there is a number of iteration is carried out till a desired output or condition is solved , we go for the 'for' statement.

LOGIC:
 Factroial of 'n' is denoted as 'n!' 

 

PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
j=1;
clrscr();
printf("Enter the n value:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
j=j*i;
}
printf("\n Factorial of %d is :%d",n,j);
getch();
}