# Control Flow Statements

In C++, conditional statements are used to control the flow of a program by allowing it to make decisions based on certain conditions. Conditional statements enable you to execute different blocks of code depending on whether a specified condition is true or false.

C++ supports several types of conditional statements, including:

1. if
    
2. if else
    
3. else if
    
4. switch
    

If: The `if` statement is used to execute a block of code if a specified condition is true.

**Syntax:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878279435/8024e679-f5de-46a1-8013-08146c916abb.png align="center")

**Example:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878506624/71cdaf8c-6d32-4b69-98f7-1012c7926f2d.png align="center")

The `if-else` statement allows you to execute one block of code if a condition is true and another block of code if the condition is false.

**Syntax:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878312481/62d14490-0b44-4ced-b56b-c2cef25b7e9b.png align="center")

**Example:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878649225/39084af4-0b4d-4278-8874-3f6512ab7a13.png align="center")

The`else-if` test multiple conditions and execute different code blocks based on which condition is true.

**Syntax:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878349371/fec5f8cd-f726-4af6-9586-dbc113af749a.png align="center")

**Example:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878946980/99bf24b0-a810-4d02-a516-e4bd983599d4.png align="center")

The `switch` statement is used when you want to select one block of code to execute from multiple possibilities based on the value of an expression.

**Syntax:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695878382137/2bc92b77-625a-401d-a4b3-a056de256dd6.png align="center")

**Example:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695879320106/559741b0-aa27-41f7-804a-2d5db0fbb5af.png align="center")

Thanks for reading,

Mohammed Muqafamuddin.
