Friday, 19 September 2014

WAP to find all Armstrong no. in range of 0 and 999

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int m,b,k,x;
printf("  Armstrong no. between 0 to 999 are ");
for(int a=0;a<=999;a++)
{
b=a;
int m=0;
while(b<0)
{
k=b%10;
m+=m+k*k*k;
b=b/10;
}
if(m==a)
{
printf("%d ",a);
}
}
getch();
}

No comments:

Post a Comment

Please write your doubts