Created
November 12, 2016 00:09
-
-
Save dyigitpolat/08d804b023b34a56238349645d114a29 to your computer and use it in GitHub Desktop.
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 "stdlib.h" | |
#include "stdio.h" | |
#include "math.h" | |
int main() | |
{ | |
int num, temp; | |
int digits; | |
int i; | |
long sum; | |
scanf( "%d", &num); | |
temp = num; | |
digits = 0; | |
while( temp) | |
{ | |
temp /= 10; | |
digits++; | |
} | |
temp = num; | |
sum = 0; | |
for( i = 0; i < digits; i++) | |
{ | |
sum += pow( temp % 10, digits); | |
temp /= 10; | |
} | |
if( sum == num) | |
printf( "%d is an armstrong number\n", num); | |
else | |
printf( "%d is not an armstrong number\n", num); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment