Thursday, September 13, 2018

FACTORIAL

  • Problem Description

    To print the factorial of the given number using pointers
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int i,f=1,n;
      scanf("%d",&n);
      for(i=1;i<=n;i++)
        f=f*i;
      printf("%d",f);
    return 0;
    }
  • Test Case 1

    Input (stdin)
    5
    
    
    Expected Output
    120
  • Test Case 2

    Input (stdin)
    7
    
    
    Expected Output
    5040

No comments:

Post a Comment