Thursday, December 22, 2011

C Program for find the armstrong no with in range..

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
 int no,num,arm=0;
 int i,rev=0;
 clrscr();
 for(i=1;i<=500;i++)
{
 num=no=i;
 arm=0;
 rev=0;
 while(no!=0)
    {
     arm=no%10;
     no=no/10;
     rev=rev+(arm*arm*arm);
    }
  if(num==rev)
    printf("\nArmsrtrong no : %d",num);
}
getch();

}

No comments:

Post a Comment