Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Functions > 10.10 FUNCTION AND DECISION STATEMENTS

10.10 FUNCTION AND DECISION STATEMENTS

There are two ways to use decision-making statements in C.

  1. Use of if ... else statement. For syntax see Table 10.6

    Table 10.6. if else statement with & without function
    Without FunctionWith 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.

  

Start a Free Trial