#include <stdio.h>
int main()
{
int n, no, last, sum = 0;
printf("Type number to check Armstrong or not : ");
scanf("%d", &n);
no = n;
while(n != 0)
{
last = n % 10;
sum += (last * last * last);
n = n / 10;
}
if(no == sum)
{
printf("\n%d is Armstrong", no);
}
else
{
printf("\n%d is not Armstrong", no);
}
return 0;
}
int main()
{
int n, no, last, sum = 0;
printf("Type number to check Armstrong or not : ");
scanf("%d", &n);
no = n;
while(n != 0)
{
last = n % 10;
sum += (last * last * last);
n = n / 10;
}
if(no == sum)
{
printf("\n%d is Armstrong", no);
}
else
{
printf("\n%d is not Armstrong", no);
}
return 0;
}
Bhuvan Arora
No comments:
Post a Comment