Pseudocode Examples

# Pseudocode Examples - Pseudocode Examples Modified 15...

This preview shows pages 1–3. Sign up to view the full content.

Pseudocode Examples Modified 15 December 1999 An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed. An algorithm is merely the sequence of steps taken to solve a problem. The steps are normally "sequence," "selection, " "iteration," and a case-type statement. In C, "sequence statements" are imperatives. The "selection" is the "if then else" statement, and the iteration is satisfied by a number of statements, such as the "while," " do," and the "for," while the case-type statement is satisfied by the "switch" statement. Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The rules of Pseudocode are reasonably straightforward. All statements showing "dependency" are to be indented. These include while, do, for, if, switch. Examples below will illustrate this notion. GUIDE TO PSEUDOCODE LEVEL OF DETAIL: Given record/file descriptions, pseudocode should be created in sufficient detail so as to directly support the programming effort. It is the purpose of pseudocode to elaborate on the algorithmic detail and not just cite an abstraction. Examples: 1. If student's grade is greater than or equal to 60 Print "passed" else Print "failed" endif 2. Set total to zero Set grade counter to one While grade counter is less than or equal to ten Input the next grade Add the grade into the total endwhile Set the class average to the total divided by ten Print the class average.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. Initialize total to zero Initialize counter to zero Input the first grade while the user has not as yet entered the sentinel add this grade into the running total add one to the grade counter input the next grade (possibly the sentinel)
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/12/2011 for the course IT 215 taught by Professor Danielreddy during the Spring '11 term at University of Phoenix.

### Page1 / 5

Pseudocode Examples - Pseudocode Examples Modified 15...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online