> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# Nested if & if/else Statements in C++
- URL: https://developerinsider.co/nested-if-statements-in-cpp/
- Published: 2016-08-06T11:51:18.000Z
- Updated: 2018-03-29T17:01:15.000Z
- Author: Anit Kumar
- Tags: Primary, C++

#### Nested if statements:

You can also include, or nest, if statements within another if statement.  
**For example:**

```
int mark = 100;

if (mark >= 50) {
  cout << "You passed." << endl;
  if (mark == 100) {
    cout <<"Perfect!" << endl;
  }
}
else {
  cout << "You failed." << endl;
}

```

**Output:**

```
You passed.
Perfect!

```

#### Nested if else Statements:

C++ provides the option of nesting an unlimited number of if/else statements.  
**For example:**

```
int age=18;
if(age>14)
{
  if(age>=18)
 {
    cout<<"Adult";
 }
  else
 {
    cout<<"Teenager";
 }
}
else
{
  if (age > 0)
 {
    cout<<"Child";
 }
  else
 {
    cout << "Something's wrong";
 }
}

```

**Output:**

```
Adult

```