006-005-012
Using Break and Continue
Medium
Problem Description
Using Break and Continue
In this problem, you will create a program that uses break to exit a loop when 5 is found and uses continue to skip even numbers and display only odd numbers, and displays the result to standard output.
Learning Objective: Understand the behavior of loop control statements break and continue
Overview
break immediately exits the loop, while continue skips the current iteration and proceeds to the next.
Specifications
- Loop from 1 to 10, break when 5 is found
- Loop from 1 to 10, skip even numbers with continue and display only odd numbers
Output Format
Break example:
1 2 3 4
Continue example:
1 3 5 7 9
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
