Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the primary purpose of a for loop?
Think about what part of the loop controls the number of executions.
Write a simple for loop that prints numbers from 1 to 5.
Remember to initialize, set a condition, and include an increment.
What type of loop guarantees that the loop's block will be executed at least once?
Consider the execution flow of each loop type.
True or False: A while loop requires that its condition be true to continue executing.
Think about how loops terminate.
Write a program that prints the factorial of a number using a for loop.
Think about how you multiply numbers from 1 to 'n'.
Create a program that asks for user input until they type 'exit', using a while loop.
Remember to set up your condition to exit correctly!
5 more questions in this section. Enroll free to practise them all.
Enroll free