Unit 2 Task 28: Stock on the shelf

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

Unit 2 Task 28 - Stock on the shelf

← Unit 2 tasks · Solution


A shop starts with S items. Repeatedly ask how many were sold this hour (integer). Subtract from stock.

Print remaining stock whenever you like (e.g. after each valid sale).

Skills: while, guards on subtraction.