What is the most favorite loop structure, and why?
How might you use it in a real business programming problem?
In loop structure, FOR loop is the most favorite one.
Unlike many other kinds of loops, such as the while loop, the for loop is often distinguished by an explicit loop counter or loop variable. This allows the body of the for loop (the code that is being repeatedly executed) to know about the sequencing of each iteration. For loops are also typically used when the number of iterations is known before entering the loop.
Consider a business firm, a program is written to find out number of old timers in that firm. For that program, a first FOR loop is used to iterate each employee and a second FOR loop is used inside the first FOR loop for each department. so from this program the old timers can easily be sort out from every department, using nested FOR loops.
Following program is used to sort the products in a market. So sorting algorithm is used in this program, using arrays.
The solution determines the most favorite loop structure. An example using a C array is analyzed.