bsc

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

pc007.c (860B)


      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 /* Armstrong number check only for three digit */
      8 
      9 #include <stdio.h>
     10 
     11 int main()
     12 {
     13     int num, temp1, armstrongCheck = 0;
     14     printf("Enter a three digit number : ");
     15     if (scanf("%d", &num) != 1)
     16     {
     17         printf("\nOnly positive number allowed.");
     18         return 1;
     19     }
     20     if (num < 100 || num > 999)
     21     {
     22         printf("\nOnly Three digit postive number allowed.");
     23         return 1;
     24     }
     25     temp1 = num;
     26     while (temp1 > 0)
     27     {
     28         armstrongCheck += (temp1 % 10) * (temp1 % 10) * (temp1 % 10);
     29         temp1 /= 10;
     30     }
     31     if (armstrongCheck == num)
     32         printf("\nInput %d is a armstrong number.", num);
     33     else
     34         printf("\nInput %d is not a armstrong number.", num);
     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