Control Structures

 Understanding about Control Structures

    We all know that a program is composed with a lot of data and a list of well defined instructions about how to access those data in order to provide a functionality or service. Data in a program can be understood when you have the idea about the variables and data structures. But to impose the instructions properly you must know about the control structures and statements. A control structure is a syntactic form in a language to express flow of control. A sequence of statements is executed depending on whether or not the condition it true or false. This means the program chooses between two or more alternative paths. Hence it is the basic decision-making process in computer programming; flow control determines how a computer will respond when given certain conditions and parameters. 

         JavaScript if else Statement By Examples

Flowchart of  if statement


    Decision making structures have on or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Decision making in programming is similar to decision making in real life. In programming also we face some situations where we want a certain block of code to be executed when some condition is fulfilled. A programming language uses control statements to control the flow of execution of program based on certain conditions.


    Looping structures are used to execute a set of instructions/functions repeatedly when some conditions become true. There are three types of loops in java. The java for loop is used to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop. The java while loop is used to iterate a part of the program several times. If the number of iteration is not fixed, it is recommended to use while loop. The java do-while loop is used to iterate a part of the program several times. Use it if the number of iteration is not fixed and you must have to execute the loop at least once.

Java for Loop (With Examples)

Flowchart of for loop


Comments