bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

P028.c (708B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* WAP to calculate factorial of a number */
      8 
      9 #include <stdio.h>
     10 int main()
     11 {
     12     int i = 1, num, fact = 1;
     13     printf("Enter the number : ");
     14     if (scanf("%d", &num) != 1)
     15     {
     16         printf("\nPlease enter a number.");
     17         return 1;
     18     }
     19     if (num == 0)
     20     {
     21         printf("\nFactorial of 0 : 1");
     22         return 0;
     23     }
     24     if (num < 0)
     25     {
     26         printf("\nFactorial of %d : UNDEFINED", num);
     27         return 0;
     28     }
     29     while (i <= num)
     30     {
     31         fact = fact * i;
     32         i++;
     33     }
     34     printf("Factorial of %d : %d", num, fact);
     35     return 0;
     36 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror