Loop Basics
While Loop
For Loop
100

What is a loop in programming?

A structure that repeats a block of code while a condition is true.

100

Will this loop run?
 int x = 10; while(x < 5) { x++; }

No

100

True or False: The update statement in a for loop is optional.

True

200

What keyword can you use to immediately exit a loop?

break

200

What happens if you forget to update the loop variable?

The loop may become infinite.

200

What type must the loop counter be?

Any numeric type (e.g., int, double)

300

What do you call a loop that never ends?

An infinite loop.

300

True or False: You must use a counter in every while loop.

False

300

Fix the error:
 for(int i = 1; i <= 5; i--)

Change i-- to i++ to avoid infinite loop.