C Program to find factorial of a number.

/* Write a C Program to find factorial of a number.  */
=======================================
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,fact=1;
clrscr();
printf(“Enter any no: ”);
scanf(“%d”,&n);
26 C P
S
ROGRAMS WITH
OLUTIONS
for(i=n;i>=1;i--)
{
fact=fact*i;
}
printf(“Factorial=%d”,fact);
getch();
}

Output:
======
Enter a no: 5
Factorial=120

No comments: