Iteration Structure

 Iteration is a type of a control structure that allows the repetition of some code. This means that there would be no code execution i.e. repeat it zero times. There can also be a fixed number of executions or indefinite executions until a certain condition is met. Iteration is also referred to as looping since for task repetition, there is back looping of the flow.

Table of Contents


In any learning environment, there is also testing of the students’ performance. Performance is greatly affected by how safe the learning environment is. The programming proposal seeks to create a project that once implemented would lead to having a safe environment of learning for the student. Thus, an iteration structure needs to be developed on the student performance.


The type iteration structure that is chosen is the do-while loop. This is also refereed to as a conditional loop. The do-while loop terminates on the basis of a condition that has been encoded. This means that the execution of a statement is done so long as the condition of the loop still holds. The do-while loop was chosen because it allows the expression to be evaluated following the execution of the statement. This then implies that execution of the statement takes place even when the expression is not found to be true (Zak, 2008). Therefore, execution goes to completion. In this form of iteration, the statement must be executed even if this is done once. Even in cases where the expression is zero, there is execution of the statement. Thus, unlike the while loop, the do-while loop is advantageous since there is no situation under which bypassing of the statement occurs.


The syntax is do statement while expression. This can be represented as:

do

{

statement;

statement;

statement;

statement;

}

while (expression)

In this case where the iteration is on performance of students, comparison is done between the performance of two classes and this is taken as a representative of the entire group. Therefore, the pseudo code will be

do


{

cout << “\nWhat is the performance of class a?”;

cin >> class a performance;

cout << “\nWhat is the performance of class b?”;

cin >> class b performance;

cout >> “\nBoth performances can be added to give:”;

cout >> (class a performance + class b performance);

cout << “\nShould it be repeated? y or n “;

cin >> loop_response;

}

while (loop_response = ‘n’)

flow chart

Reference

Zak, D. (2008). Microsoft Visual Basic 2008: Reloaded. 3rd Ed. Cengage Learning.





Is this your assignment or some part of it?

We can do it for you! Click to Order!



Order Now


Translate »

You cannot copy content of this page