Hello friends i hope you all are doing great. In this tutorial, we will Discuss Concept of Programming Loops. There is very less program that does the operations only a single time. For instance, the word processing program permits us to put more than one word in the file, and then the operating network at your computer permits us to operate numerous applications before you shut down the computer.
Program loops permit the computer to implement a similar group of instruction numerous times. So let’s get started with Concept of Programming Loops.
Simple Program Loop
- The program loop is a series of execution in which the program comes back to the earlier location of execution creating a loop.
- In the below figure you can see the flowchart for a simple program loop.
- The flowchart in the above figure indicates that execution goes by the instructions in the program loop and the last command is known as loop instruction changes the execution back to the ist instruction in loop.
- This curve rout provides the program loop. Loop instruction and the program loops they form can be conditional or unconditional.
- The conditional loop will implement only if a certain condition is fulfilled. Mostly program loops are conditional loops.
- The 3 main categories of conditional loops are mention here first is FOR TO STEP second is WHILE DO and third is REPEAT UNTIL loop.
- The unconditional loop will cause the program loop to implement indefinitely.
- The loop which implements indefinitely is known as the infinity loop. Infinity loop can outcomes from programming or system mistakes but they are used in such operations that should operate indefinitely.
- Operation systems embedded application in useable devices and automation networks are infinity loop.
FOR-TO-STEP Loop
- The FOR TO STEP loop is a program loop that uses the counter or index value to find whether it must repeat or exit the loop.
- The programmer adjusts the starting end and step parameters for the loop index that is counter which retains track of how much time the loop has implemented.
- The below figure indicates the flowchart for the FOR TO STEP LOOP.
- You can see flowchart indicates the FOR TO STEP loop indicates the initial end and step parameters and starts the loop index to initial parameters.
- The program loop then implements the loop instruction and sets the loop index through the step point.
- If the loop index not larger than then end parameter the loop repeats than the program exists the loop.
- Observe that if the step value for loop is negative the loop index will reduce with another loop.
- Numerous programs use negative step parameters and endpoint of zero since processors can easily note for zero value.
WHILE-DO Loop
- The FOR TO STEP Loop is beneficial for an application that has a range of loop condition parameters is known already.
- But in some cases, the range for certain electric features is no known. The VGS off and IDSS parametrs for FET for instance can change for every number.
- The FOR TO STEP loop can operate numerous times and larger the extreme rating for UUT or it can operate some time and not applicable the signals required to accurately test UUT.
- While DO lopp finds the solutions. in place operating the loop a defined time the While DO loop indicates certain situation to finds continuous or nor.
- In this method, the loop operates numerous times as shown in below figure WHILE DO Loop.
- Observe that the WHILE DO doe not automatically modify the situation which at last ends the loop. The loop commands should find info get during loop and after the end situation at the accurate time.
- Observe that loop will not implement if the situation is at start FALSE.
REPEAT-UNTIL Loop
- The REPEAT UNTIL loop is different from WHILE DO loop in 2 ways.
- it finds a certain condition at the end of loop.
- It remains in the loop while a certain condition is FALSE and exist when the condition is true.
Nested Loops
- We can put a loop in the loops to make nested loops. The nested loop are used for the program should implement an operation numerous times when the task itself should implement numerous times.
- An example of this is a program used for an auto insertion machine in electronic assembly lining.
- The auto insertion machine put numerous portions on blank circuitry boards.
- The outer loop processes the numerous circuitry board and comprises an internal loop that puts numerous portions on every board.