#include<stdio.h>
#include<math.h>
int main()
{
int upper , lower , i , x , y , rem =0 , n =0, sum =0 ;
printf(" Enter the upper limit : ");
scanf(" %d ", &upper);
printf(" \n Enter the lower limit : ");
scanf(" %d", &lower);
for(i=upper+1 ; i<lower ; i++)
{
x = i;
y = i;
while( x > 0)
{
x = x/10 ;
n++;
}
while( y > 0)
{
rem = y %10 ;
sum= sum + pow(rem,n);
y = y/10 ;
}
if( sum == i)
printf(" %d ",i);
n=0;
sum=0;
}
return 0;
}
OUTPUT :
Enter the upper limit : 999
Enter the lower limit : 99999
1634 8208 9474 54748 92727 93084
#include<math.h>
int main()
{
int upper , lower , i , x , y , rem =0 , n =0, sum =0 ;
printf(" Enter the upper limit : ");
scanf(" %d ", &upper);
printf(" \n Enter the lower limit : ");
scanf(" %d", &lower);
for(i=upper+1 ; i<lower ; i++)
{
x = i;
y = i;
while( x > 0)
{
x = x/10 ;
n++;
}
while( y > 0)
{
rem = y %10 ;
sum= sum + pow(rem,n);
y = y/10 ;
}
if( sum == i)
printf(" %d ",i);
n=0;
sum=0;
}
return 0;
}
OUTPUT :
Enter the upper limit : 999
Enter the lower limit : 99999
1634 8208 9474 54748 92727 93084
0 Comments