Module 3: Control Structure - Selectors Flashcards

(31 cards)

1
Q

are used to control the flow of program execution by employing decision making, looping and branching, enabling your program to conditionally execute particular blocks of code

A

Control Structures

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

depends on the supplied data values and the conditional logic specified

A

Program Execution Order

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

Three Types of Control Statements

A
  1. Conditional/Selector Statement
  2. Iteration/Loop Statement
  3. Jump Statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the conditional/selector statements?

A
  • if statement
  • if-else statement
  • nested-if statement
  • switch-case statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the iteration/loop statements?

A
  • for statement
  • while statement
  • do-while statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the jump statements?

A
  • break

- continue

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

decide which statement to execute and when

A

Selection/Decision Making Statement

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

Selection statements evaluate the _____ and control the program flow depending upon the result of the condition provided

A

Boolean expression

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

Three Types of Selection Statements

A
  1. Single Way Selection (if)
  2. Two Way Selection (if-else)
  3. Multiple Selection (nested if and switch-case)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  • It is a simple decision-making statement
  • It is used to decide whether the statement or block of statements should be executed or not
  • Block of statements will be executed if the given condition is true otherwise the block of the statement will be skipped
A

Single Way Selection (If Statement)

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

Syntax for If Statement

A
Syntax:
if (condition) {
           stmt1;
           stmt2;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

is an extension to the if-statement, which uses another block of code, i.e., else block

A

If-Else Statement

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

is executed if the condition of the if block is evaluated as false false

A

Else Block

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

Syntax for If-Else Statement

A
Syntax:
if (condition) {
            stmt1;
            stmt2;
   }
else {
            stmt3;
            stmt4;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

contains the if-statement followed by multiple else-if statements

A

Nested-If/If-Else-If Statement

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

It is the _____ that creates a decision tree where the program may enter in the block of code where the condition is true.

A

chain of if-else statements

17
Q

The last else statement will be executed if all if condition is _____

18
Q

Syntax for Nested-If/If-Else-If Statement

A
Syntax:
if (condition1) {
        stmt1;
        stmt2;
 }
 else if (condition2){
           stmt3;
           stmt4;
  }
  else if (condition3){
               stmt5;
               stmt6;
    }
    else {
                  stmt7;
                  stmt8;
       }
19
Q

are similar to if-else-if statements

A

Switch Statements

20
Q

The _____ contains multiple blocks of code called _____ and a single _____ is executed based on the variable which is being switched.

A

switch statement; cases; case

21
Q

The switch statement is easier to use instead of _____.

A

if-else-if statements

22
Q

Syntax for Switch Statement

A
Syntax:
switch () {
            case  : 
stmt1;
stmt2;
break;
            case  : stmt3;
stmt4;
break;
            case  : stmt5;
stmt6;
break;
            default: stmt7;
stmt8;
} // end switch
23
Q

set what variable needs to be tested based on its value

A

Switch (Variable)

24
Q

value tested base on the value of the variable indicated in switch

25
terminates the enclosing switch statement.
Break
26
are necessary because without them, statements in switch blocks fall through
Break Statements
27
this statement is performed if none of the case labels are true. It is similar to the last else of the nested-if statement.
Default
28
is used when dealing with conditions whose value to be tested has a single value only.
Switch Statement
29
Only ______ case body in the switch statement is executed
ONE
30
used to test a range of values
Nested If
31
used to test a constant value
Switch-case