5 IF
1
5 IF
2
5 IF
3
5 IF
4
1
The IF-ELSE statement allows you to do different things
depending on a condition, (temp > 37.0) in this case
First we need to understand how to write conditions.
5 IF
5
5 IF
6
5 IF
7
5 IF
8
2
5 IF
9
5 IF
10
5 IF
11
5 IF
12
3
5 IF
13
5 IF
14
5 IF
15
5 IF
16
4
temp > 37
yes
no
cout << “fever”
5 IF
17
This version is for
when you only need
one statement in each
branch.
Otherwise use {}
braces to group
together the multiple
statements
5 IF
19
cout << “fine”
5 IF
18
Suppose we want to do more things if someone has
a fever: (see temp-IF-multiple.cpp)
The { } braces group together multiple statements
to form the “what to do if true”
part.
5 IF
20
5
5 IF
21
5 IF
23
5 IF
22
6
© Copyright 2026 Paperzz