#include <stdio.h>
#include <math.h>
int main()
{
int low , high , num , onum , rem , count = 0;
int result = 0 ;
printf("Enter the values of n1 and n2 separated by space : ");
scanf("%d %d" , &low , &high);
printf("Armstrong numbers between %d an %d are : " , low , high);
for (num = low ; num <= high ; ++num )
{
onum = num ;
while (onum != 0)
{
onum = onum / 10 ;
++count ;
}
onum = num ;
while (onum != 0)
{
rem = onum % 10 ;
result += pow(rem , count);
onum /= 10 ;
}
if (result == num)
{
printf("%d " , num);
}
count = 0 ;
result = 0 ;
}
printf("\n");
return 0 ;
}
No comments:
Post a Comment