mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-21 21:11:57 +03:00
initial
This commit is contained in:
parent
0d51baac64
commit
14487c6e25
24
isArmstrong.C
Normal file
24
isArmstrong.C
Normal file
@ -0,0 +1,24 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user