If Statement in C++

Decision Making:

The if statement is used to execute some code if a condition is true.
Syntax:

if(condition)
{
//statements
}

The condition specifies which expression is to be evaluated. If the condition is true,the statements in curly brackets are executed.

If statement:

Use relational operators to evaluate conditions.
For example:

if(4>2)
{
cout<<"True";
}

Output:

True

The if statement evaluates the condition (4>2), finds it to be true ,and then executes the cout statement. If we change the greater operator to less than operator (4>2), the statement will not be executed and nothing will be printed out.


Share Tweet Send
0 Comments
Loading...
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.