//Program to display Armstrong numbers between 1 to 500
#include<stdio.h>
#include<conio.h>
int main()
{
int n,num,sum=0,rem,k;
clrscr();
printf("Armstrong numbers between 1 to 500 are\n");
for(n=1;n<500;n++)
{
n=k;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n/10;
}
if(sum==k)
printf("%d",k);
}
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.
#include<stdio.h>
#include<conio.h>
int main()
{
int n,num,sum=0,rem,k;
clrscr();
printf("Armstrong numbers between 1 to 500 are\n");
for(n=1;n<500;n++)
{
n=k;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n/10;
}
if(sum==k)
printf("%d",k);
}
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.