Check whether the given number is Armstrong Number or not.
#include<math.h>
void main() {
int i;
int temp;
int digit;
int number;
int sum = 0;
int count = 0;
printf("Enter number : ");
scanf("%d", &number);
temp = number;
while(temp != 0) {
count++;
temp /= 10;
}
temp = number;
while(temp != 0) {
digit = temp % 10;
sum += pow(digit, count);
temp /= 10;
}
if(sum == number) {
printf("%d is armstrong number\n", number);
}
else {
printf("%d is not armstrong number\n", number);
}
}
0 Comments