Created
September 18, 2017 12:12
-
-
Save ericdeans/9fb3703b6da21ca6bc45e6d40430b4da to your computer and use it in GitHub Desktop.
Program To Check Armstrong Number of Three Digits.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int number, originalNumber, remainder, result = 0; | |
printf("Enter a three digit integer: "); | |
scanf("%d", &number); | |
originalNumber = number; | |
while (originalNumber != 0) | |
{ | |
remainder = originalNumber%10; | |
result += remainder*remainder*remainder; | |
originalNumber /= 10; | |
} | |
if(result == number) | |
printf("%d is an Armstrong number.",number); | |
else | |
printf("%d is not an Armstrong number.",number); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To learn this program,you should have basic knowledge of C Programming and Freedom apk.
The output for the above program would be:
Enter a three digit integer: 371
371 is an Armstrong number.