There are two ways to use decision-making statements in C.
Use of if ... else statement. For syntax see Table 10.6
Table 10.6. if else statement with & without function
Without Function
With Function
if(condition)
Statement1;
else
Statement1;
}
The if … else statement is used to make the decision in the program at the run time. It decides which statement to execute and which statement to bypass, depending up certain conditions.
The above syntax is used commonly in the program.
if(fun())
statement1;
else
statement2;
where fun() is a function.
Here, in this example, instead of writing condition directly we are passing function. Here when the if() statement executes control is passed in the function fun(). The return value of function is used for condition.
You are currently reading a PREVIEW of this book.
Get instant access to over
$1 million worth of books and videos.