The blocks “if” and “otherwise” may include any other statements, including other nested conditional statements; while the else statement refers to the nearest previous if

Example
if ( A > 10 )
  if ( A > 100 )
    cout << "You have a lot of money.";
  else
    cout << "You have enough money.";
else
    cout << "You have not enough money.";
To make it easier to understand the program, all the blocks “if” and “otherwise” (together with the brackets enclosing them) are shifted to the right by 2-3 characters — such a record is called a “ladder” record
Recording "ladder" is a good form for any programmer!

Task
Using the nested conditional operator, write a program that will display the word "YES" if the number entered from the keyboard is in the range from 20 to 40, and the word "NO" otherwise.

Complete the original program with the necessary conditions.

Please note that there are two else branches in the program - if any of the conditions is not met, the word NO must be displayed.
C++
1
#include <iostream>     
2
using namespace std;  		     
3
main()       
4
{       
5
int n;  	     
6
cin>>n;       
7
8
9
    cout<<"YES";       
10
   else       
11
      cout<<"NO";       
12
else       
13
   cout<<"NO";       
14
}        
Your last submission is saved in the editor window.
     

Results:

All results: