Short Q/A Loop Control Structure - Students Free Notes

What is an infinite loop? Give an example.

An infinite loop is a loop that never terminates because its condition always evaluates to true, or there’s no exit condition defined. It continues to execute indefinitely until it is manually interrupted or the program is terminated. Example of an infinite loop: while(1) { printf(“This is an infinite loop\n”); } The condition 1 is always … Read more

Differentiate between break and continue statements.

The break and continue statements are used to control the flow of execution in loops, but they serve different purposes: break: This statement is used to exit a loop completely, terminating it regardless of whether the loop’s condition has been satisfied. It is often used when a certain condition is met, and there’s no need … Read more