Module: Nested conditional statement. Difficult conditions


Problem

1/13

Nested conditional statement

Theory Click to read/hide

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

For example: 
if ( A > 10 ) if ( A > 100 ) cout << "You have a lot of money."; else cout << "You have enough money."; else cout << "You don't have enough money."; To make it easier to understand the program, all "if" blocks and "else" (together with the brackets that delimit them) are shifted to the right by 2-3 characters - such an entry is called a ladder entry.

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, and the word "NO< /code>" 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.