C++ Programming Code Examples C++ > If Else and Switch Case Code Examples The if-else Statement The if-else Statement The if statement by itself will execute a single statement, or a group of statements, when the expression following if evaluates to true. It does nothing when the expression evaluates to false. Can we execute one group of statements if the expression evaluates to true and another group of statements ifthe expression evaluates to false? Of course! This is what is the purpose of the else statement that is demonstrated as if (expression) { block of statement; } else statement; The group of statements after the if upto and not including the else is called an if block. Similarly,the statements after the else form the else block. Notice that the else is written exactly below the if. The statements in the if block and those in the else block have been indented to the right. Had there been only one statement to be executed in the if block and only one statement in the else block we could have dropped the pair of braces. As with the if statement, the default scope of else is also the statement immediately after the else. To override this default scope a pair of braces as shown in the above "Multiple Statements within if" must be used.