If
else statement in C
When making a decision there are always two faces to
it do or not to do.
Similarly when programming there are two faces to a
condition , it may evaluates as TRUE or FALSE .
To implement such a decision , C has provided a
construct called If-Else.
The construct carries out a logical test and then
takes one of the two possible course of actions, depending on the outcome of
the test.
The syntax of if else construct is as follows,
if(condition)
{
Statement1;
}
else
{
Statement2;
}
If the condition with in the parenthesis of if
statement is true, then the statement immediately following it is executed,
otherwise the statement following the else is executed.
The flow chart for if else statement is as follows,
Example program:
Output:
Thank you …
0 comments: