Decision structure in C++

Слайд 2

Let there are multiple statements in the code. This program provides

Let there are multiple statements in the code. This program provides

an ability to the programmer to decide what statements to be executed and what statements should not be executed depending upon the specific condition. This is known as decision making
Слайд 3

Decision-making is an important concept in any programming language and to

Decision-making is an important concept in any programming language and to

accomplish this, C++ uses the following decision making statements:

if statement
if..else statement
switch statement
conditional operator

Decision making statements

Слайд 4

IF statement if statement allows us to control a program whether

IF statement

if statement allows us to control a program whether to

execute specific statement or not.
If statement is used to complete an operation, if a condition is true
Condition can be true or false
The condition will be checked and if it is true then the statement will be executed.
Слайд 5

IF…ELSE statement The if...else executes body of if when the condition

IF…ELSE statement

The if...else executes body of if when the condition is true and executes the

body of else if condition is false.
Слайд 6

SWITCH statement. Allows selection among multiple sections of code, depending on

SWITCH statement.

Allows selection among multiple sections of code, depending on the

value of an integral expression.
A switch statement includes one or more switch sections. Each switch section contains one or more case labels followed by one or more statements.