# Program to find whether 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 = 1^{3} + 5^{3} + 3^{3}

1634 = 1^{4} + 6^{4} + 3^{4} + 4^{4}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include<stdio.h> #include<conio.h> #include<math.h> #include<stdlib.h> void 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"); getch(); exit(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%ld is an armstrong number",num); } else{ printf("\n%ld is not an armstrong number",num); } getch(); } |

**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.??