The Simple if Statement
Learn how C++ uses the simple if conditional statement.
We'll cover the following
In programming, we often come across points where we have to make a decision based on some certain input or output of a statement. In C++, to do this, we use some statements called conditional statements. We'll start with the most basic conditional statement, the if
statement.
if()
statement
The if statement takes one argument of type bool
or a function with return type bool
. Upon execution of the if
statement, the compiler moves to the if enclosed bracket if and only if the condition inside the if
statement is true
. Here, take a look at the flow diagram of the working conditional statement.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy