If – else statement in c++ with example

The if – else statement is an extension of the simple if statement.

Syntax:-

if(condition)
{
True - Block of Statement
}
else
{
False - Block of Statement
}
Statement;

Note:-

# Condition can be expression or relation.
# If body of statement is only one statement than braces ({}) are not needed.
# Body of the statement may have one or more statement.
# Either true – block of statement or false – block of statement is executed, not both.

Execution:-

If condition is true than true - block of statement is executed otherwise false - block statement is executed than control is moved to statement next to if statement.

Examples:-

Program to find even number



Program to find greatest number between 2



One Comment

  1. if i need decision from multiple selection, what do i do then.... your coding explanation is better to code with C ++ Language

    ReplyDelete

Add your comments here

Back to Top