Skip to content

Commit

Permalink
Merge pull request seeditsolution#177 from VighneshManjrekar/patch-1
Browse files Browse the repository at this point in the history
Create Armstrong.c
  • Loading branch information
seeditsolution authored Oct 2, 2020
2 parents 4ae8c0f + 1b7a6bf commit e9448c8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Armstrong.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 e9448c8

Please sign in to comment.