Check Armstrong number in an array - C Program

Write a C program to store N elements in an array and then check how many elements are Armstrong number in that array.

Solution:

Armstrong Number:  
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 153 is an Armstrong number since 1*1*1 + 5*5*5 + 3*3*3 = 153

We will use a "for loop" to find the Armstrong numbers from the array.

Program

#include<conio.h>
#include<stdio.h>
#define max 100
void armstrng(int[],int);
void main()
{
       int a[max], n, i=0;
       printf("Enter the limit of array: ");
       scanf("%d", &n);
       printf("Enter the elements of array: ");
       for(i=0; i<n; i++)
       {
              scanf("%d",&a[i]);
        }
        armstrng(a,n);
        getch();
}
void armstrng(int a[max],int n)
{
        int i=0, temp, sum=0, rem, c=0;
        for(i=0; i<n; i++)
        {
              sum=0;
              temp=a[i];
              while(a[i]!=0)
              {
                      rem=a[i]%10;
                      sum=sum+rem*rem*rem;
                      a[i]=a[i]/10;
               }
               if(temp==sum)
               {
                       c++;
              }
        }
        printf("\nTotal armstrng no is: %d ",c);
}


Output:

armstrong no