Unit 2 Task 43: Count digits in a sale ID

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 43 - Count digits in a sale ID

← Unit 2 tasks · Solution


A sale ID is a positive integer. Count how many digits it has by repeatedly dividing by 10 (integer division) until the number becomes 0.

Example: 905 has 3 digits.

Skills: while, //.