ABSTRACT

In real life, we encounter many problems where we need to decide what to do and what not to do. Consider a problem to check whether a number is even or odd. If the given number is divisible by 2, then it is even; otherwise, it is odd. Hence it includes a decision. Similarly, we may have problems that need some work to be done repeatedly. So, to solve these kinds of problems, we need the concept of control structure. Control structure determines the flow of control in a program, that is, it indicates the order in which the various instructions in a program are executed inside the computer. This chapter describes several control statements used in C, such as if-else, switch, while, do-while, goto, and for. Among these control statements, if-else and switch are used to solve decision-making problems. However, while, do-while, and for control statements are used for solving problems that require some statements to be executed multiple times.