Write a C program to find the factorial of a given number.
#include<stdio.h>
main()
{
int fact=1, i,n;
printf("enter the number:\n ");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf("%d factorial is the : %d",n,fact);
}
OUTPUT:
enter the number:
4
4 factorial is the : 24
#include<stdio.h>
main()
{
int fact=1, i,n;
printf("enter the number:\n ");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf("%d factorial is the : %d",n,fact);
}
OUTPUT:
enter the number:
4
4 factorial is the : 24
No comments:
Post a Comment