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
What are the different constructs of flow of control used in a program?Marks:1
Three types of constructs are used in a program, i.e., sequence, iteration and selection.
Name the data types that can be used in switch statements.Marks:1
The data type of expression in switch statements must be byte, char, short or int type.
How are expressions evaluated in if-else-if ladder?Marks:1
Expressions are evaluated from the top downward.
Write the syntax of if statement.Marks:1
The syntax of if statement is as follows:
What do you mean by Flow of Control?Marks:1
Flow of Control refers to the order in which the statements and instructions of a program are executed or evaluated.