Program to Find Factorial of a Number
#include<stdio.h>
//declaration of function
int fact(int);
void main()
{
int a,d;
printf("enter the number: ");
scanf("%d",&a);
d = fact(a); //function calling
printf("\nthe factorial of entered number is %d",d);
}
//definition of function
int fact(int x)
{
int i=1,b=1 ;
while(i<=x)
{
b = b*i;
i++;
}
return b;
}
If You Liked This Post Please Take a Time To Share This Post
0 comments:
Post a Comment