Print Factorial | User Given Number | Using Function | C-Program
To print factorial user given number
Tips:
- Loop is required.
- Concept of factorial required, example: (5!= 5 x 4 x 3 x 2 x 1)
Note : This program is written using a function.
Code :
#include<stdio.h>
void main()
{
factorial();
getch();
}
factorial()
{
int i,n,b=1;
printf("Enter a number to factorial:\n");
scanf("%d",&n);
for(i=n;i>=1;i--)
b=b*i;
printf("%d factorial is %d \n",n,b);
}
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)