0% found this document useful (0 votes)
24 views

Control Statements

Control statements are used to control the flow of a program. There are different types of control statements including decision making statements like if/else statements and switch statements, as well as loop statements like for, while, and do-while loops. If statements can be simple if statements, if/else statements, nested if statements, or if/else-if ladders. Loop statements repeat a block of code a specified number of times or until a condition is met.

Uploaded by

Ashi Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Control Statements

Control statements are used to control the flow of a program. There are different types of control statements including decision making statements like if/else statements and switch statements, as well as loop statements like for, while, and do-while loops. If statements can be simple if statements, if/else statements, nested if statements, or if/else-if ladders. Loop statements repeat a block of code a specified number of times or until a condition is met.

Uploaded by

Ashi Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Control

Statements
SHUBHANSHU & AYUSH
What are Control statements are used in a
programming language to control the flow
of the program. They are nothing but a
control keyword or statements that are used in a
program to transfer the flow of control to
statements? another statement based on the
conditions.
There are various types of control
flow statements

01 DECISION MAKING STATEMENTS:


If Statements. Types
Switch Statements.
of
02 LOOP STATEMENTS:
For loop. Control
While loop.
Do while loop. Statements.
THERE ARE VARIOUS TYPES OF IF STATEMENTS

01 IF STATEMENT

Types 02 IF/ELSE STATEMENT

of
If Statements. 03 NESTED IF STATEMENT

04 IF/ELSE-IF LADDER
Simple If Statement
It is the most basic statement among all control flow
statements in C++.
It evaluates a Boolean expression and enables the
program to enter a block of code if the expression
evaluates to true.
Simple If Statement
If
If/Else Statement

The if-else statement also tests the condition.


It executes when if condition is true otherwise
else block is executed.
If/Else Statement
If

Else
Nested If Statement

The nested if statement represents the if block


within another if block. Here, the inner if block
condition executes only when outer if block
condition is true.
Nested If Statement

te s
Ne
d

If
If-Else-If Ladder

The if-else-if ladder statement executes one


condition from multiple statements.
If

If/Else-If Ladder

se
El f
I
Switch Statement

The switch statement executes one statement


from multiple conditions. It is like if-else-if ladder
statement in C++.
Switch Statement

h
itc
Sw
THERE ARE VARIOUS TYPES OF LOOPS

Types 01 FOR LOOP

of 02 WHILE LOOP

Loops. 03 DO WHILE LOOP


For Loop

The for loop is used to repeat a part of the program several


times. If the number of repetition is fixed, it is recommended to
use for loop.
For Loop

r
Fo
While Loop

The while loop is considered as a repeating if statement. If


the number of repetition is not fixed, it is recommended
to use the while loop.
While Loop
li e
h
W
Do-While Loop

The do-while loop is used to perform a part of the program


several times. If the number of repetition is not fixed and you
must have to execute the loop at least once, it is
recommended to use do-while loop.
Do-While Loop
Do

hile
W
Thank
you!!

You might also like