> ## 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.

# If else statement in C++
- URL: https://developerinsider.co/if-else-statement-in-cpp/
- Published: 2016-08-04T14:18:50.000Z
- Updated: 2018-03-29T17:01:15.000Z
- Author: Anit Kumar
- Tags: Primary, C++

##### Else statement:

An if statement can be followed by an optional else statement, which executes when the condition is false.  
**Syntax:**

```
if(condition)
{
//statements
}
else
{
//statements
}

```

The compiler will test the condition:  
:-If it evaluates to true, then the code inside the if statement will be executed  
If it evaluates to false, then the code inside the else statement will be executed.  
**For examle:**

```
int mark=90;
if(mark<33)
{
cout<<"You failed"<<endl;
}
else
{
cout<<You passed"<<endl;
}

```

**Output:**

```
You passed

```

\*\*Note:-\*\*When only one statement is used inside the if/else, then the curly braces can be omitted.