Print armstrong number between 100 to 999 using One Dimensional Array in C


This program is about check using for loop and if conditions and print armstrong numbers between 100 to 999 in array

Source Code

#include<stdio.h>
int main()
{
  int i,j=0,n=999,m[1000],a,b,c,d,e;
  printf("\nArmstromg number betweeen 100 to 999 are:");
  for(i=100;i<n;i++)
  {
    a=i/10;
    b=i%10;
    c=a/10;
    d=a%10;
    b=b*b*b;
    c=c*c*c;
    d=d*d*d;
    e=b+c+d;
    if(i==e)
    {
      j++;
      printf("\nm[%d]=%d",j,i);
    }
  }
  printf("\nTotal number of amstrong no's=%d",j);
  return 0;
}
            
To download raw file Click Here

Output

Armstrong number between 100 to 999
m[1]=153
m[2]=370
m[3]=371
m[4]=407
Total number of armstrong no's=4

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes