C Program to print Armstrong numbers between the given two numbers.
Armstrong numbers :
ArmstrongNumbers.c
#include<stdio.h>
int main(void)
{
int x,y,n,num,cube,d,sum;
printf("Enter x and y values to print Armstrong numbers: \n");
scanf("%d%d",&x,&y);
printf("Armstrong numbers are :\n");
for(num=x; num<=y; num++)
{
n=num;
sum=0;
while(n>0)
{
d=n%10;
n/=10;
cube=d*d*d;
sum=sum+cube;
}
if(num==sum)
printf("%d\n",num);
}
return 0;
}
Output:
Terminal
Enter x and y values to print Armstrong numbers:
50
1500
Armstrong numbers are :
153
370
371
407
Happy Learning 🙂