Subscribe to:
Post Comments
(
Atom
)
Input number: 4
Factorial: 24
What is factorial?
Factorial of a number n is product of all positive integers less than or equal to n. It is denoted asn!.For example factorial of 5 = 1 * 2 * 3 * 4 * 5 = 120Factorial code :#include<stdio.h>int main(){int n,i,fac=1;printf("Enter any number to calculate factorial: ");scanf("%d",&n);for(i=1;i<=n;i++){fac=fac*i;}printf("Factorial of %d = %d",n,fac);}output :
No comments