Program to check if a number is Armstrong or not
Definition (Armstrong Number): An n-digit number equal to the sum of the nth powers of its digits.
Example:
153 = 13 + 53 + 33
1634 = 14 + 64 + 34 + 44
#include<stdio.h>
#include<math.h>
int main(){
long int num =153, count = 0, i, temp1, temp2, temp3 = 0;
clrscr();
printf("Enter the number: ");
scanf("%ld",&num);
if(num <= 0){
printf("\nEnter the number greater than 0");
return 0;
}
temp1 = temp2 = num;
while(temp1!=0){
temp1=temp1/10;
count++;
}
for(i=0;i < count; i++)
{
temp3 = temp3 + pow((temp2%10),count);
temp2 = temp2/10;
}
if(num == temp3)
{
printf("\n %d is an armstrong number",num);
}
else
{
printf("\n %d is an armstrong number",num);
}
return 0;
}
Output:
Enter the number: 92727
92727 is an armstrong number
Have any questions regarding this program? Post a comment.

Nice share
it can be also written simpler than this. without using and so confusion don’t arrives.
Can u plz tell us different math.h functions you have used.??