Skip to content

Instantly share code, notes, and snippets.

@dyigitpolat
Created November 12, 2016 00:09
Show Gist options
  • Save dyigitpolat/08d804b023b34a56238349645d114a29 to your computer and use it in GitHub Desktop.
Save dyigitpolat/08d804b023b34a56238349645d114a29 to your computer and use it in GitHub Desktop.
#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