TheAlgorithms-C/math/is_armstrong.c
Defective Detective 56b72da9fb
chore: move various misc folder... (#1177)
...algorithms to the `math` folder.

Co-authored-by: David Leal <halfpacho@gmail.com>
2022-12-22 11:26:50 -06:00

25 lines
408 B
C

#include <stdio.h>
int main()
{
int n, sum = 0, i, num;
printf("Enter number: ");
scanf("%d", &n);
num = n;
while (n != 0)
{
i = n % 10;
sum = sum + (i * i * i);
n = n / 10;
}
if (sum == num)
{
printf("%d is an armstrong number!\n", num);
}
else
{
printf("%d is not an armstrong number!\n", num);
}
return 0;
}