100% found this document useful (1 vote)
319 views

Lesson 8 Nested If Else Statement

This document discusses nested if/else statements in C++. It explains that nested if/else statements allow multiple test expressions to be evaluated, with the code blocks under each if or else executing conditionally. It provides an example of using nested if/else to check a user's body temperature and determine if they have a fever or not. It also gives another example to validate if a character entered by the user is a valid alphabet letter or not, and if so, to further check if it is a vowel or not.

Uploaded by

j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
319 views

Lesson 8 Nested If Else Statement

This document discusses nested if/else statements in C++. It explains that nested if/else statements allow multiple test expressions to be evaluated, with the code blocks under each if or else executing conditionally. It provides an example of using nested if/else to check a user's body temperature and determine if they have a fever or not. It also gives another example to validate if a character entered by the user is a valid alphabet letter or not, and if so, to further check if it is a vowel or not.

Uploaded by

j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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