You are on page 1of 8

NESTED IF ELSE

STATEMENT
WHAT IS A NESTED IF ELSE
STATEMENT?
HOW DOES IT WORKS INSIDE C++
PROGRAM

C++ provides the option of nesting an unlimited number of if/else statements.


 Nested if...else are used if there are more than one test expression..
 If the first test expression is true, it executes the code inside the braces { } just below it.
 But if the first test expression is false, it checks the second test expression.
 If the second test expression is true, if executes the code inside the braces { } just below it.
This process continues.
 If all the test expression are false, code/s inside else is executed and the control of program
jumps below the nested if...
FLOWCHART OF NESTED IF
ELSE
SYNTAX:
EXAMPLE CODE: Create a C++ program using nested if else to check
whether the number entered by the user is greater than or equal.
EXAMPLE CODE: Create a program to determine if you can join a
team or not.
ACTIVITY:

Problem 1: Create a C++ program using Nested if else statement that


will monitor your body temperature. If with fever , make some alert
messages in response to covid 19.

BODY TEMPERATURE
TEMPERATURE DESCRIPTION
35.0 ° C – HYPOTHERMIA
36. 5 ° C – NORMAL
37.5 ° C – FEVER
Problem 3:
Create a C++ program using Nested if else statement that will read a
character from the user and validating that it is valid alphabet or not, if the
character if valid alphabet then we are validating it is VOWEL or not and
printing the appropriate message for the input character.

You might also like