006-003-004
While Loop: Countdown
Easy
Problem Description
while loop: Countdown
In this problem, you will create a program that reads an integer and counts down from that number to 0, displaying each value on a separate line using a while loop.
Learning Objective
Learn how to use while loop for repetition.
Problem
Create a program that counts down from an input number to 0. Set a condition like while (n >= 0), then in each iteration print the current value and decrement the variable by 1.
Input
Line 1: Starting number (integer)
Output
Display countdown numbers on each line.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up