If Else in C++ Programming Language

Aman Kharwal
3 min readOct 24, 2020

In this article, I will introduce you to the if else statement from the C ++ programming language which is used in programming to create decision making programs.

There are three types of if else statements in programming; if / else, else if and nested if. At the end of this article, you will learn all about if else statements and how to implement them using the C ++ programming language.

What is an If Else statement?

In programming languages, an if else statement is a conditional statement that executes a different set of statements depending on whether an expression is true or false. These statements are used to create programs that are based on the decision making issues of the user.

The If else statements are one of the most important fundamentals of programming as these conditionals statements are a part of almost every programming language. From basic programming language to tasks like web development and machine learning it is used in every domain of programming.

If Else Statement in C++

Now let’s cover the concept of the conditional statements by using the C++ programming language. I will first cover all three types of If else statements using C++ then at the end I will make a program by using all the three types of these conditional statements.


The if block is used to specify the code to execute if the condition specified in if is true, the else block is executed otherwise:

Else if

To specify multiple if conditions, we first use if, then consecutive statements use else if:

Nested if

To specify conditions within conditions we make the use of nested ifs. Now I will make a full-fledged if else program with all the three types of conditional statements that will be based on conditions to go for outing with either selecting one from two girls (based on our budget) or choosing to go out with friends if we are having a low budget.

So this is how we can use the If else statements in the C++ programming language. I hope you liked this article on If else or the conditionals statements in C++ programming language. Feel free to ask your valuable questions in the comments section below.