C++ if…else statement

There is two part of this statement. First is the if statement, here it checks for the condition to be true and if it is true then it will execute the code present inside the if. But if the condition is false then the code inside the else statement will be executed. if statement block with else statement is known as an if…else statement. else portion is non-compulsory.

Structure of if…else

Example:

output:

If the condition is true, then the compiler will execute the if a block of statements, if false then else block of statements will be executed. We can use multiple if-else for one inside other this is called Nested if-else.

1 thought on “C++ if…else statement”

Comments are closed.