Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
1.0k views
in Flow of Control by (49.1k points)
closed by

Explain about parts of a loop.

1 Answer

+1 vote
by (54.8k points)
selected by
 
Best answer

Every loop has four elements that are used for different purposes.

These elements are:

1. Initialization expression

2. Test expression

3. Update expression

4. The body of the loop

1. Initialization expression(s) : 

The control variable(s) must be initialized before the control enters into loop. The initialization of the control variable takes place under the initialization expressions. The initialization expression is executed only once in the beginning of the loop.

2. Test Expression : 

The test expression is an expression or condition whose value decides whether the loop-body will be executed or not. If the expression evaluates to true (i.e., 1), the body of the loop is executed, otherwise the loop is terminated.

In an entry – controlled loop, the test – expression is evaluated before the entering into a loop whereas in an exit-controlled loop, the test – expression is evaluated before exit from the loop.

3. Update expression :

It is used to change the value of the loop variable. This statement is executed at the end of the loop after the body of the loop is executed. 

4. The body of the loop :

A statement or set of statements forms a body of the loop that are executed repetitively. In an entry – controlled loop, first the test-expression is evaluated and if it is nonzero, the body of the loop is executed otherwise the loop is terminated. In an exit – controlled loop, the body of the loop is executed first then the test – expression is evaluated. If the test – expression is true the body of the loop is repeated otherwise loop is terminated.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...