mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
24 lines
305 B
C++
24 lines
305 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!", num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
printf("%d is not an armstrong number!", num);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|