PROGRAM TO ILLUSTRATE FACTORIAL OF A GIVEN NUMBER
// prg to illustrate factorial of a given number
#include<stdio.h>
void main()
{
int n,fact=1,num;
printf("enter any number:");
scanf("%d",&n);
num=n;
while(n != 0)
{
fact = fact * n;
n--;
}
printf("%d factorial is %d \n",num,fact);
}
output:
No comments:
Post a Comment