Pseudocode Fixed Loop Examples

The document contains 12 practice problems for writing pseudocode algorithms. The problems cover a range of tasks including calculating totals, averages, percentages, and costs based on different conditions. Loops are required to process repeated calculations for numbers within given ranges. Test data and trace tables are suggested to validate the algorithms work as intended.

Pseudocode conventions and control structure examples of if then else, case, while, for, do while and repeat until. 1 Overview No standard for pseudocode syntax exists. However, there are some commonly followed conventions to help make pseudocode written by one programmer easily understood by another programmer. Most of these

Loop Examples Dave Braunschweig. Counting Pseudocode This program demonstrates While, Do, and For loop counting using user-designated start, stop, and increment values. 3 Enter increment value 1 While loop counting from 1 to 3 by 1 1 2 3 Do loop counting from 1 to 3 by 1 1 2 3 For loop counting from 1 to 3 by 1 1 2 3 Flowchart

Basics There are 3 main types of loops in pseudocode, Do loops, While loops, and For loops. Loops are also known as iteration, meaning the repetition of a block of code. For Loops in Pseudocode. For Loops also known as definite or count-controlled iteration are the perfect way to iterate through a list or an array.

LOOP WHILE condition statements END LOOP Example count 0 LOOP WHILE count . 5 OUTPUT count count count 1 END LOOP This loop will output the numbers 0 through 4. For more information on variables, refer to the Variables in Pseudocode guide. Nested Loops. Loops can be nested inside other loops.

FOR Loop Use when you know the exact number of iterations. Ideal for counting and processing arrays or collections of known size. Examples Iterating over a list of students, summing a fixed number of values, etc. WHILE Loop Use when the number of iterations is unknown but controlled by a condition that is checked before each iteration. It

5.7 End fixed loop In the above example, the algorithm is designed in such a way that if a pupil has the same username as one already stored, the code will add one to their age and attempt to

For example, consider the following pseudocode again, this is an expression, not an instruction Loops Loops perform a set of actions some number of times. The one that is used a lot makes the computer follow a series of instructions a fixed number of times. For example, the following loop will execute 100 times, with n taking on

Running total within a loop example 1 fixed loop This program is used to calculate the sum of a known number of values entered by the user one at a time. 1. SET total to 0 2. Fixed loop FROM 1 TO 10 DO 3. RECEIVE number FROM KEYBOARD 4. SET total TO total number 5.END Fixed loop Running total within a loop example 2 conditional loop

For this, there are 3 types of loops iteration FOR count-controlled will execute code a fixed number of times, either known at write time e.g. a fixed number of students in a class or runtime e.g. looping through every character in a string entered by the user