If-else construct

The most commonly used conditional statement is the if-else construct. The building block of the if-else structure contains an if keyword, followed by a boolean expression and a set of curly brackets to specify the steps to execute. Optionally, there could be an  else keyword, followed by curly brackets for the code to execute when the if block is false:

int a = 5;
if (a == 5)
{
// As a is 5, do something
}
else
{
// As a is not 5, do something
}

The if-else construct can also have an else-if statement to specify multiple criteria for execution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.156.161