Selection: IF…THEN…ELSE…ENDIF (Two-Way) Nesting
Reading:
Nesting in selection constructs, such as “if-then-else” statements, involves placing one conditional block within another. This technique allows for more intricate decision-making logic, enabling programs to handle complex scenarios. Here’s an
example in Pseudocode:
DECLARE X : INTEGER
IF X>=0
THEN
OUTPUT “Positive Number”
IF X = 0
THEN
OUTPUT “But equal to 0”
ELSE
OUTPUT “But greater than 0”
ENDIF
ELSE
OUTPUT “surely x is negative”
ENDIF
In this nested “if-then-else” construct, the outer condition checks if “x” is greater than 5. If true, it further evaluates whether “x” is equal to 10. Nested constructs allow for fine-grained control over program flow, facilitating the implementation of sophisticated decision-making processes.
Apply the code in the pseudocode editor given below.
Instructions:
Press the Maximize button to change it to full screen.
Delete sample code file from right side
Create new file with name of Qno1 and start writing Pseudocode
Construct all the questions given in the interactive book.
“<-” use it to put arrows in for the assignment.
There are three areas: “files”, “editor”, “Console”
Press the “Mark as Complete” button to finish the lecture.
