Control Statements Flashcards
What is the use of the if -else control structures
They are used to test conditions.
Check the syntax for if statements
if statement syntax if(condition){ //code to be executed }
What is the C++ if else statement syntax
if statement syntax if(condition){ //code to be executed }
What is the C++ If - else-if ladder Statement
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 }
What does a switch statement do in C++
Executes one statement from multiple conditions.
What is the syntax of the switch statement
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; }
What is the use of a for loop
It is used to iterate a part of the program several times.
! If the number of iteration is fixed !
What is the syntax of a for loop
for(initialization; condition; incr/decr){ //code to be executed }
What is a nested for loop
This is a for loop inside another for loop
What is a while loop
it is a structure used to iterate a part of the program several times .!If the number of iterations is not fixed !
What is the syntax of a while loop
while(condition){ //code to be executed }