0

Get stuck

Guys I don t know how to eliminate the greater number from a number ex from 5912 output should be 512 this is problem and should use while loop Requirement A natural number N is read from the keyboard. Calculate the minimum number obtained by removing a single digit from the initial number. Input data Read the natural number N. from the keyboard. Output data The minimum number will be displayed after deleting a digit. Restrictions and specifications 0 <N <1,000,000,000 Example Input data Output data 5912 512

11th Mar 2021, 9:32 AM
Andrei Macovei
Andrei Macovei - avatar
4 ответов
0
Num%10 will give you reminder (the last digit). Num/10 give you eliminated last digit. So loop this will give you iterating to individual digits. You can find by if-Else which one is greater. Now again loop through, you can remove big number.
11th Mar 2021, 9:50 AM
Jayakrishna 🇮🇳
0
And how I eliminate the greater digit?
11th Mar 2021, 2:43 PM
Andrei Macovei
Andrei Macovei - avatar
0
If you try finding big number that way, you can get idea to eliminate it similar way.. By removed digits, you can form the same number by adding to new variable. In that process ,you can skip adding big number. Hope you can find , better solution once it worked that way... Adding if r is reminder of original Number N, then r=N%10; new1=r*10+new1; will form new number...
11th Mar 2021, 5:28 PM
Jayakrishna 🇮🇳
0
And how can I rebuild the number in the same while loop?
14th Mar 2021, 4:42 PM
Andrei Macovei
Andrei Macovei - avatar