Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What does the 'break' statement do in a loop?
Think about stopping the loop completely.
What does the 'continue' statement do?
Consider moving to the next repeat without completing the current one.
What happens when a 'break' statement is executed in a loop?
Remember, it's all about stopping the loop.
The 'continue' statement is used to:
Think about what continuing means.
Suppose you are modeling a factory with machines that can fail. Write a program that counts the number of machines that are operating based on a condition. If a machine fails, you break out of the count and report the total number of functioning machines. How would you implement this?
Remember to decide on your condition for functioning.
Create a program that processes user input and skips invalid entries (like negative numbers) using 'continue'. Once valid inputs are received, sum those values up until the input ends.
What needs to be checked before adding to the sum?
5 more questions in this section. Enroll free to practise them all.
Enroll free