# Maximum number without a digit

Hello! I had to solve this problem and I got the next solution. A natural number N is read from the keyboard. Calculate the minimum number obtained by removing a single digit from the initial number. #include <iostream> using namespace std; int main() { int N; int copyOfN; int newN = 0; int index = 0; cin >> N; copyOfN = N; int i = 1; while (N != 0) { if ((N % 10) < ((N / 10) % 10)) { index = i; } N = N / 10; i++; } i = 1; while (copyOfN != 0) { if (index--) { newN = newN + ( copyOfN % 10 ) * i; i = i * 10; } copyOfN = copyOfN / 10; } cout << newN; return 0; } The question is: How can I modify the above solution to solve the following similar problem: Requirement A natural number N is read from the keyboard. Calculate the maximum number obtained by removing a single digit from the initial number. I tried to compare this time if the last digit is higher than the penultimate digit, to put an index there, but the problem is that it compares my last digit (or the first digit of the number) with the digit 0, when the number runs out of digits.