#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n, temp, rem, digits=0, sum=0;
cout << "Enter a armstrong number: ";
cin >> n;
temp = n;
digits = (int)log10(n) + 1;
while (n != 0) {
rem = n % 10;
sum = sum + pow(rem, digits);
n = n / 10;
}
if (temp == sum) {
cout << "yes";
}
else {
cout << "not";
}
}
How does the " digits = (int)log10(n) + 1; " line actually calculates the digits? can anyone explain?