bsc

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

APC-PRAC-033.c (930B)


      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 /* Print the factorial of the digits off a number */
      8 /* Auhtor: Amit Dutta, Date: 20-11-2025 */
      9 
     10 // This code has not been compiled.
     11 // If you find any issues, please create a new issue on GitHub regarding them.
     12 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     13 
     14 #include <stdio.h>
     15 
     16 int factorial(int);
     17 
     18 int factorial(int n)
     19 {
     20     int i, fact = 1;
     21     for (i = 1; i <= n; i++)
     22         fact *= i;
     23     return fact;
     24 }
     25 
     26 int main()
     27 {
     28     int n, temp;
     29     printf("Enter the number: ");
     30     scanf("%d", &n);
     31     if (n < 0)
     32     {
     33         printf("Only non-negetive number is allowed.");
     34         return 1;
     35     }
     36     temp = n;
     37     while (temp > 0)
     38     {
     39         printf("\nFactorial of %d: %d", temp % 10, factorial(temp % 10));
     40         temp /= 10;
     41     }
     42     return 0;
     43 }
© 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