Basic in c


//program to print out all Armstrong numbers between 1 and 500.

#include<stdio.h>
#include<conio.h>
void main()
{
int c,s,r1,r2,r3;
clrscr();
printf(“All Armstrong no. between 1 to 500:\n\n”);
c=1;
while(c<=500)
{
r1=c-((c/10)*10);
r2=(c/10)-((c/100)*10);
r3=(c/100)-((c/1000)*10);
s=(r1*r1*r1)+(r2*r2*r2)+(r3*r3*r3);
if(s==c)
{
printf(“\n%d”,s);
}
c++;
}
getch();
}

SHARE
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment