Skip to content

Commit

Permalink
Create arm.c
Browse files Browse the repository at this point in the history
  • Loading branch information
SrijanZ authored Oct 21, 2020
1 parent 9c1c24e commit f82742f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions arm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
int main() {
int num, originalNum, remainder, result = 0;
printf("Enter a three-digit integer: ");
scanf("%d", &num);
originalNum = num;

while (originalNum != 0) {
// remainder contains the last digit
remainder = originalNum % 10;

result += remainder * remainder * remainder;

// removing last digit from the orignal number
originalNum /= 10;
}

if (result == num)
printf("%d is an Armstrong number.", num);
else
printf("%d is not an Armstrong number.", num);

return 0;
}

0 comments on commit f82742f

Please sign in to comment.