so I have tried a lot of different things to try to get these functions to work but have not been able to get them working together. The problem is to output armstrong numbers within a certain range selected by the user. please help
Code:
bool IsArmstrongNumber(int x)
//-----------------------------------------------------
{
int NumberOfDigits(int x);
int DthDigitOfX(int x,int d);
int sum,d;
int n = NumberOfDigits(x);
for(d=0;d<=n;d++)
{
x=n%10;
sum+=DthDigitOfX(x,d);
n=n/10;
}
if (x==sum)
{
return(true);
}
else
{
return(false);
}
}
Code:
int DthDigitOfX(int x,int d)
Code:
//-----------------------------------------------------
{
/*
Precondition: (x >= 0)
Precondition: (1 <= d <= 10)
d is interpreted as follows
1
d = 0,987,654,321
x = X,XXX,XXX,XXX
For example, if x = 153, then
d = 1 returns 3,
d = 2 returns 5,
d = 3 returns 1, and
d > 3 returns 0.
*/