0% found this document useful (0 votes)
4 views10 pages

Nested If

The document explains nested if statements, including their syntax, structure, and use in pseudocode and flowcharts. It provides an example of a nested if statement to check exam marks and determine the results. It also includes an activity to write a nested if statement to check two workers' ages and determine their eligibility to work.

Uploaded by

Shaday Dyght
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Nested If

The document explains nested if statements, including their syntax, structure, and use in pseudocode and flowcharts. It provides an example of a nested if statement to check exam marks and determine the results. It also includes an activity to write a nested if statement to check two workers' ages and determine their eligibility to work.

Uploaded by

Shaday Dyght
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

NESTED IF

BY: K.MORGAN
OBJECTIVES:

1.Explain the term nested-if


2.Identify the structure of a nested -if.
3.Represent algorithm in the form of a ‘pseudocode’ using
selection control structure.
4. Represent algorithms in the form of a ‘flowchart’
WHAT IS NESTED IF?

A nested-if is an if statement
that is the target of another IF
statement.
The nested-if statement executes one condition from multiple

statements. The execution starts from top and checked for each if

condition.

The statement of if block will be executed which evaluates to be

true. If none of the if condition evaluates to be true then the last

else block is evaluated.


SYNTAX FOR NESTED-IF
•If (condition1)
<Executes when condition1 is true>
• if (condition2)
• <Executes when condition2 is true>
• else
• <Executes else when is false>
QUESTION
•If the mark is 80 or greater, then the statements for “ Excellent results!” will be output.

•Otherwise, if the mark is 70 or greater, then the statement for “satisfactory result” will be
output.

•However, regardless of the mark, another statement to await the end of the term report
is also output.
PSEUDOCODE FOR THE NESTED IF
FLOWCHART
NESTED-IF ACTIVITY

•Write a structured algorithm to input the age of two workers.


If age is less than 18 display “you are a minor” and “ you are
not eligible to work”. If age is less than or equal to 60 display “
You are eligible to work” and “Please fill in your details and
apply” .Otherwise, display “ you are too old to work as per the
Government rules” and “ Collect your pension”.

You might also like