bsc

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

root / semester_1 / practice-c / pc007.c

pc007.c (724B)


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