Control Statements Flashcards

1
Q

What is the use of the if -else control structures

A

They are used to test conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Check the syntax for if statements

A
if statement syntax 
if(condition){
//code to be executed
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the C++ if else statement syntax

A
if statement syntax 
if(condition){
//code to be executed
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the C++ If - else-if ladder Statement

A
if(condition1){    
//code to be executed if condition1 is true    
}else if(condition2){    
//code to be executed if condition2 is true    
}    
else if(condition3){    
//code to be executed if condition3 is true    
}     
else{    
//code to be executed if all the conditions are false    
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does a switch statement do in C++

A

Executes one statement from multiple conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the syntax of the switch statement

A
switch(expression){      
case value1:      
 //code to be executed;      
 break;    
case value2:      
 //code to be executed;      
 break;    
......      
default:       
 //code to be executed if all cases are not matched;      
 break;    
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the use of a for loop

A

It is used to iterate a part of the program several times.

! If the number of iteration is fixed !

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax of a for loop

A
for(initialization; condition; incr/decr){    
//code to be executed    
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a nested for loop

A

This is a for loop inside another for loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a while loop

A

it is a structure used to iterate a part of the program several times .!If the number of iterations is not fixed !

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the syntax of a while loop

A
while(condition){    
//code to be executed    
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly