bsc

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

APC-PRAC-037.c (1202B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Show all the armstrong number between a range. */
      9 /* Author: Amit Dutta, Date: 21-11-2025 */
     10 
     11 // This code has not been compiled.
     12 // If you find any issues, please create a new issue on GitHub regarding them.
     13 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     14 
     15 #include <stdio.h>
     16 #include <math.h>
     17 
     18 #define lowerBound 100
     19 #define upperBound 999
     20 
     21 int isArmstrongNumber(int);
     22 
     23 int isArmstrongNumber(int n)
     24 {
     25     int temp = n, sum = 0, count = 0;
     26     while (temp > 0)
     27     {
     28         count++;
     29         temp /= 10;
     30     }
     31     temp = n;
     32     while (temp > 0)
     33     {
     34         sum += (int)pow(temp % 10, count);
     35         temp /= 10;
     36     }
     37     return sum == n;
     38 }
     39 
     40 int main()
     41 {
     42     int n, i, count = 0;
     43     printf("Armstrong number between %d and %d are:  ", lowerBound, upperBound);
     44     for (i = lowerBound; i <= upperBound; i++)
     45         if (isArmstrongNumber(i))
     46         {
     47             printf("%d  ", i);
     48             count++;
     49         }
     50     printf("\n\nCount: %d\n", count);
     51     return 0;
     52 }
© 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