Monday, 1 July 2019

Program to calculate factorial of a number

Input :-







Output :-






Code :-

 #include <stdio.h>

    int main()
    {
      int c, n, fact = 1;

      printf("Enter a number \n");
      scanf("%d", &n);

      for (c = 1; c <= n; c++)
        fact = fact * c;

      printf("The factorial of %d is = %d\n", n, fact);

      return 0;
    }




0 Comments:

Post a Comment

Popular Posts

Categories

Android (21) AngularJS (1) Books (3) C (75) C++ (81) Data Strucures (4) Engineering (13) FPL (17) HTML&CSS (38) IS (25) Java (85) PHP (20) Python (83) R (68) Selenium Webdriver (2) Software (13) SQL (27)