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 = 13 + 53 + 33
1634 = 14 + 64 + 34 + 44

#include
#include
#include
#include
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

Output:

Enter the number: 92727

92727 is an armstrong number

Have any questions regarding this program? Post a comment.

You may also like...

4 Responses

  1. Sam says:

    Nice share

  2. it can be also written simpler than this. without using and so confusion don’t arrives.

  3. Anonymous says:

    Can u plz tell us different math.h functions you have used.??

  1. March 2, 2014

    […] Program to find whether a number is Armstrong or not […]

Leave a Reply

Your email address will not be published. Required fields are marked *