0% found this document useful (0 votes)
61 views8 pages

Hsslive-7 Control Statements

This document compares and contrasts control statements in C++ including if/else if statements versus switch statements, entry-controlled versus exit-controlled loops, and provides the syntax for switch statements, while loops, for loops. The key differences covered are: switch statements use equality checks while if/else if can use any relation, default is used for switch while else is used for if/else if, and break is required to exit switch but if/else if exits automatically. Entry-controlled loops check the condition before the body while exit-controlled check after and ensure the body runs at least once.

Uploaded by

Kedar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views8 pages

Hsslive-7 Control Statements

This document compares and contrasts control statements in C++ including if/else if statements versus switch statements, entry-controlled versus exit-controlled loops, and provides the syntax for switch statements, while loops, for loops. The key differences covered are: switch statements use equality checks while if/else if can use any relation, default is used for switch while else is used for if/else if, and break is required to exit switch but if/else if exits automatically. Entry-controlled loops check the condition before the body while exit-controlled check after and ensure the body runs at least once.

Uploaded by

Kedar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

7 Control Statements -

Important Questions and Answers


Compare switch statement and else if ladder.

If .. else if switch
Any relational condition Only quality condition
can be checked can be checked.
else block is executed if default block is executed
all conditions are false if all cases are false

Automatically to come break is required to come


out of if structure out of switch structure

2
Write the syntax of switch statement ?

switch (expression)
{
case constant 1: statement block 1;
break;
case constant 2: statement block 2;
break;
.
.
default : statement block n;
}

3
Differentiate between entry-controlled loop and
exit controlled loop.

entry-controlled loop exit controlled loop


Condition is evaluated after Body of the loop is executed
initialisation after initialisation
Body of loop may never Body of loop executed at
executed least once
Example : while loop , for Example : do while loop
loop

4
Write the syntax of while loop. ?

initialisation ;
while(condition)
{
body of the loop;
updation;
}

5
Write the syntax of for loop. ?

for (initialisation ; condition ; updation)


{
body of loop;
}

6
List the four components of a loop statements.

1. Initialisation
2. Condition
3. loop body
4. Updation

7
There are three looping statements in c++.?
a) Which is the exit – controlled loop ?
b) How does it differ from an entry controlled loop?

Answer :
a) do while
b) In exit – controlled loop, the conditon is evaluated only after
executing body of the loop.

You might also like