Question

What is the purpose of indentation in loops?


To count the number of loops


To make the code look pretty


To show which instructions belong to the loop


To skip parts of the code

Answers

GPT-4o mini
The purpose of indentation in loops is **to show which instructions belong to the loop**.

In many programming languages (like Python), indentation is crucial for defining the scope of loops and conditionals. It indicates which statements are part of the loop body and ensures that the control flow of the program is correctly interpreted. Proper indentation helps improve code readability and organization, but its primary function in the context of loops is to define what code executes within that loop.

Related Questions