C Programming – Control Structures

Control Structures – C Programming

Being human we perform different sets of actions in our daily life. We take decisions by evaluating certain parameters. If it is raining outside, then I would take an umbrella. If the highway is busy I would take a diversion. If I like this post l would subscribe this website in facebook.  You can notice all these decisions depend on some condition being met.

C language too must be able to perform different sets of actions depending on the circumstances.

Control Statements

In computer programming, all programs structures can be written using a combination of only three control structures; sequential, selective and repetitive. The sequential structure consists of a sequence of program statements that are executed one after another in order, the selective structure consists of a test for a  condition   followed   by  alternative   paths  that  the program can follow, and the repetitive structure consists of  program  statements   that  are  repeatedly  executed while some conditions holds true. Each of the structures is explained below.

Control Structures in C programming

Control Structures in C programming

  1. Sequential structure: In  this  type  of  control  statement,   all  the  codes  are executed  one  after  another  in  sequence.  None of the codes are repeated and there are no any conditions. They are direct in structure. They have a continuous flow of control.  Line by line compiling is done from top to bottom without any repetition and selection.
  2. Selective structure: The selective structure allows the usual sequential order of execution to be modified. It consists of a test for a condition followed by alternative paths that the program can follow. The program selects one of the alternative paths based upon the result of the test for the condition. This structure of selection is done by the statements like if, if-else, switch in C language. They logically make decision by evaluating two or more parameters.
  3. Repetitive Structure(Iteration): The repetitive structure allows repeating the block of statement whenever necessary. It consists of test for condition and as the condition matches the test then the block of statement is repeated for a given time. Repetitive structures in C language are performed by the statements such as for, do-while, while. They perform test on variables and make decision to either repeat the block of statement or not and for how many times by defining an end variable.

Importance of Control Structures

In C programming, Control Structures enables a programmer to write his program with different structures, it encourages making programming easy by facilitating selection among different lists, making decision and at same time branching among different functions of the program. The main advantages of Control Structures in C programming is that it decreases the line of code to be written by providing repetitive structures. While building an application, a programmer needs to go through many repetitions and selections which are controlled be control structures.

In other part we will include different sub divisions of Control Structures.