How do you validate to only input 5 digits number? If it's more than 5, then it tries again. | Sololearn: Learn to code for FREE!
0

How do you validate to only input 5 digits number? If it's more than 5, then it tries again.

12th Nov 2021, 3:19 AM
Kaizuke
Kaizuke - avatar
2 odpowiedzi
12th Nov 2021, 4:03 AM
Ipang
0
If your number is a whole number and in a number type variable you can use division of the base type to calculate to determine length of the number. If it is in string format use stolen(). Ie Get your number Check to ensure it's not 0 and flip your negatives to a positive. Set a counter variable Divide your number by ten Add one to your counter Check for zero Loop or have final answer.
12th Nov 2021, 1:02 PM
William Owens
William Owens - avatar