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
0 votes
90 views
in Control Statements by (29.8k points)
closed by

Explain different loops in detail?

1 Answer

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

1. For loop: 

The syntax of for loop is for(initialization; checking ; update loop variable) 

Body of loop; 

First part, initialization is executed once, then checking is carried out if it is true the body of the for loop is executed. Then loop variable is updated and again checking is carried out this process continues until the checking becomes false. It is an entry controlled loop.

eg: for(i=1,j=1;i<=10;i++,j++) 

cout<<i<<"x"<<j<<" = "<<i x j;

2. While loop: 

It is also an entry controlled loop The syntax is given below 

Loop variable initialised while(expression) 

Body of the loop; 

Update loop variable; 

Here the loop variable must be initialised outside the while loop. Then the expression is evaluated if it is true then only the body of the loop will be executed and the loop variable must be updated inside the body. The body of the loop will be executed until the expression becomes false. 

eg: 

i = 1; 

j = 1; 

while(i<=10) 

{

cout<<i<<" x <<j<<" = "<<i x j;i++;

j++;

}

3. do While loop: 

It is an exit controlled loop. The syntax is given below 

do 

Statements 

}while(expression); 

Here the body executes atleast once even if the condition is false. After executing the body it checks the expression if it false it quits the body otherwise the process will be continue.

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.

...