Introduction to Control Statements

Introduction to Control Statements

Published by: Nuru

Published date: 21 Jun 2021

Introduction to Control Statements Photo

Introduction to Control Statements

In an introduction to control statements, we say that they are the statements that determine whether other statements will be executed. In C programs, we execute statements sequentially in the order in which they appear in the program. They are the primary building blocks of a program. It is a complete instruction to the computer to carry out some tasks. Control statements enable us to specify the order in which the various instructions in the program are to be executed. This determines the flow of control. Control statements define how the control is transferred to other parts of the program.

Brief description of Control Statements

The statements such as sequence, selection, iteration, and jump statements control the flow of the execution of the program. And, we call them program control statements. The common control statements available in C are:

  • Sequence control statements: They execute the set of statements sequentially one after the other.
  • Selection statements: We also call them branching created using if-else, if-else if, switch.
  • Repetition Statements: They are also known as looping statements. We create the looping by using while, do-while, for.
  • Jump Statements: We create these using goto, break, continue.

The normal flow of execution in a high-level language is sequential. That is, there is the execution of each statement in the order of its appearance in the program. However, depending on the requirement of a problem, it might require altering the normal sequence of execution in a program. The statements which specify the order of execution of statements are control flow statements. Actions may be in the form of data movement, decision-making, etc.

There are also some other statements such as assignment statements, function statements, and label statements. The assignment statement is the workhouse of many programs. It assigns a value to the variable. It consists of a variable name followed by the assignment operator (=). A semicolon follows this. A function statement causes the function to do whatever it does. For instance, we invoke the printf () function to print some results. We create the label statements using case, default. There is the use of label statements with other statements such as a switch, goto, etc.