-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx04.01.txt
More file actions
11 lines (11 loc) · 692 Bytes
/
Ex04.01.txt
File metadata and controls
11 lines (11 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
1. When would you use a while loop?
It allows code to be executed repeatedly based on a given boolean condition.
We use it when the amount of iterations are unknown.
2. When would you use a do/while loop?
A do while loop executes a block of code at least once and then repeatedly executes the block or
not depending on a given boolean condition at the end of the block.
3.When would we use a for loop?
A for loop (or simply loop) is a statement for specifiying iteration, which allows code to be executed repeatedly.
for loops are typically used when the number of iterations are known.
4.Can any one of these loops be substututed for anoher?
A while loop can be written as a do while loop.