Module: Nested conditional statement. Difficult conditions


Problem

1/14

Nested conditional statement

Theory Click to read/hide

Into "if" blocks and "otherwise" may include any other statements, including other nested conditional statements; the else statement refers to the nearest previous if

For example 
if A > 10 then
  if A > 100 then
    writeln('You have a lot of money.')
  else
    writeln('You have enough money.')
else
    writeln('You don't have enough money.')
To make it easier to understand the program, all "if" blocks and "otherwise" (together with then and begin - end) are shifted to the right by 4 characters - such an entry is called a ladder entry
Record "ladder" is good form for any programmer!

Problem

Using a nested conditional statement, write a program that will display the word "YES" if the number entered from the keyboard is between 20 and 40 inclusive, and the word "NO" otherwise.

Complete the original program with the necessary conditions.

Please note that the program has two else branches - if any of the conditions is not met, the word NO must be displayed on the screen.