Search C Program

Armstrong Numbers upto N

/* Print Armstrong Numbers upto N */

#include<stdio.h>

int main()
{
    int i,j,sum,n;

    printf("Please enter the value of N: ");
    scanf("%d",&n);
   
    for(i=2;i<=500;i++)
    {
        for(j=i,sum=n;j>=1;j=j/10)
            sum=sum+(j%10)*(j%10)*(j%10);
        if(sum==i)
            printf("%d is Armstrong.\n",i);
    }
    return 0;
}

Related Links:
Check Armstrong Number 
http://cbasicprogram.blogspot.in/2012/05/check-armstrong-number.html

3 comments: