Selection Statements

Control statements control the flow of the program execution either by repeating or skipping the set of statements based on the result of the test condition. Control statements are categorized into four parts i.e., sequential statement, selection statement, looping statement and jump statement.

The sequential statement does not contain any test condition. A condition check always gives either of the following two values: True or False. The various types of selection statements are single selection, double selection and multiple selection statement. The if statement is used to check a test condition in a program. The if-else-if ladder is used to check more than one condition. The switch statement is used to execute the statements based on more than one test condition. If control flows to the next case below the matching case, in absence of break, it is called fall-through. The conditional operator operates with three operands thus it is also called ternary operator.

To Access the full content, Please Purchase

  • Q1

    What are the different constructs of flow of control used in a program?

    Marks:1
    Answer:

    Three types of constructs are used in a program, i.e., sequence, iteration and selection.

    View Answer
  • Q2

    Name the data types that can be used in switch statements.

    Marks:1
    Answer:

    The data type of expression in switch statements must be byte, char, short or int type.

    View Answer
  • Q3

    How are expressions evaluated in if-else-if ladder?

    Marks:1
    Answer:

    Expressions are evaluated from the top downward.

    View Answer
  • Q4

    Write the syntax of if statement.

    Marks:1
    Answer:

    The syntax of if statement is as follows:

    if (expression)

    Statement;

    View Answer
  • Q5

    What do you mean by Flow of Control?

    Marks:1
    Answer:

    Flow of Control refers to the order in which the statements and instructions of a program are executed or evaluated.

    View Answer