I need to determine whether an entered number has digits in ascending order from right to left.
My code seems not working correctly
Here is my code:
int n, temp; cout << "Please enter number: "; cin >> n; bool ascending = true; temp = n%10; while (n>0) { n /= 10; if (temp < n % 10) { ascending = false; } } if (ascending) { cout << "Number is ascending"; } else { cout << "Number is not ascending"; }
couts to keep updated on the values of variables and where the control flow is going.