bsc

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

root / semester_1 / tuition-c / APC-PRAC-033.c

APC-PRAC-033.c (794B)


      1 /* Print the factorial of the digits off a number */
      2 /* Auhtor: Amit Dutta, Date: 20-11-2025 */
      3 
      4 // This code has not been compiled.
      5 // If you find any issues, please create a new issue on GitHub regarding them.
      6 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      7 
      8 #include <stdio.h>
      9 
     10 int factorial(int);
     11 
     12 int factorial(int n)
     13 {
     14     int i, fact = 1;
     15     for (i = 1; i <= n; i++)
     16         fact *= i;
     17     return fact;
     18 }
     19 
     20 int main()
     21 {
     22     int n, temp;
     23     printf("Enter the number: ");
     24     scanf("%d", &n);
     25     if (n < 0)
     26     {
     27         printf("Only non-negetive number is allowed.");
     28         return 1;
     29     }
     30     temp = n;
     31     while (temp > 0)
     32     {
     33         printf("\nFactorial of %d: %d", temp % 10, factorial(temp % 10));
     34         temp /= 10;
     35     }
     36     return 0;
     37 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror