The if else statement is a type of control structure. A control structure is a instruction, statement or group of statements which determines the sequence of execution of other statements. The basic operation of if else statement is that a statement or group of statements is executed under if, if the value of expression is true and if the expression is false, statements under else are evaluated. In C++ language, zero is false everything else is true. Statement associated either with if or else are executed not both group of statements are executed. The else clause is optional.
The general form of if else statement is:
if (expression){OR
statement;
}
else{
statement;
}
if (expression){The curly braces mark the beginning and the end statements under if and else. Here is a program which illustrates the functioning of if else statement :
statement;
}
Output of this code:
Enter your mark
45
RESULT IS D
Press Enter to return to Quincy...
إرسال تعليق
Thank you for vising