diff --git a/arm.c b/arm.c new file mode 100644 index 0000000..12d5f69 --- /dev/null +++ b/arm.c @@ -0,0 +1,24 @@ +#include +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; +}