Advertisement
afrinahoque

Calculate the factorial of a number

Jun 11th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.18 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.   int i,f=1,n;
  5.  
  6.   printf("Enter a number: ");
  7.   scanf("%d",&n);
  8.   for(i=1;i<=n;i++)
  9.     f=f*i;
  10.   printf("Factorial of %d: %d",n,f);
  11.   return 0;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement