Explore BrainMass

Most favorite loop structure

What is the most favorite loop structure, and why?
How might you use it in a real business programming problem?

Give an example of how you might use a C array to solve a real life business problem.
Extra(notreally!): post a code sample too.

© BrainMass Inc. brainmass.com July 18, 2018, 5:03 am ad1c9bdddf

Solution Preview

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.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* ...

Solution Summary

The solution determines the most favorite loop structure. An example using a C array is analyzed.