Pseudo Code
Pseudo Code
Pseudo Code
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.
Examples:
Print "passed"
else
Print "failed"
else
4.
else
For looping and selection, The keywords that are to be used include Do While...EndDo; Do
Until...Enddo; Case...EndCase; If...Endif; Call ... with (parameters); Call; Return ....; Return;
When; Always use scope terminators for loops and iteration.
As verbs, use the words Generate, Compute, Process, etc. Words such as set, reset, increment,
compute, calculate, add, sum, multiply, ... print, display, input, output, edit, test , etc. with careful
indentation tend to foster desirable pseudocode.
Pseudocode
Definition - What does Pseudocode mean?
Pseudocode is an informal program description that does not contain code syntax or underlying
technology considerations. Pseudocode summarizes a program’s steps (or flow) but excludes
underlying details.
System designers write pseudocode to ensure that programmers understand a software project's
requirements and align code accordingly. It can be anything from a few scribbles on a piece of
paper, to detailed designs using a modeling language.
Structured English is native English language used to write the structure of a program whereas,
Pseudo Code is more close to programming language.
Structured English is native English language used to write the structure of a program module by
using programming language keywords, whereas, Pseudo Code is more close to programming
language and uses native English language words or sentences to write parts of code.
Programming Tools
During programming analysis and system design, the programmers, system engineers and system
designers work together to build a successful program or a computer-based information system.
Various ideas, components and program modules are integrated to accomplish the task.
System analysts and designers perform the following tasks during these steps.
The programming tools give the idea how the flow should take place in order to accomplish a
task. Several programming tools are used in this context. Some of the most common
programming tools are:
1. Pseudo code
2. Algorithm
3. Flowchart
Pseudo code
Pseudo code is a combination of two words: Pseudo and Code. 'Pseudo' means imitation and
'code' refer to instruction written in the programming language. Pseudo code is not a real
programming code. It is the generic way of describing an algorithm without using any specific
programming language-related notations.
The pseudo code cannot be compiled. It cannot be executed and there are no real formatting or
syntax rules for writing pseudo codes.
It is simply an important step in producing the final code. Some important terms used in pseudo
code for different activities are:
The two major constructions in pseudo code structures are: Sequence and Selection (decision).
Sequence indicates the continuous flow of the program, whereas selection uses logical
comparison or conditional check for making decisions.
Example:
……………
IF (condition> THEN
List of Actions
ELSE
END IF
………………
…………………
Example:
READ A, B, AND C
IF A is greater than C
THEN
DISPLAY A
ELSE
DISPLAY C
END IF
ELSE
IF B is greater than C
THEN
DISPLAY B
ELSE
DISPLAY C
END IF
END IF
STOP
Example:
ADD 1 to Count
PRINT Count
ENDDO
STOP
Algorithm
An algorithm is defined as a finite sequence of explicit instructions that produces an output with
the set of input values. The steps in the algorithm are never ambiguous. It terminates after a finite
number of steps.
Algorithms can have repetitions and logical decisions until a specific task is completed.
Algorithms are not computer programs. They cannot be executed by the computer.
Properties of Algorithm
Go to step 2}
Step 4: Speak
Example: Write an algorithm to find the largest number among three input numbers.
Step 1: Start
Step 4: Find the largest number between MAXAB and C and store
it in MAX
Step 6: Stop
Write the algorithm to calculate the interest on principle amount in N number of Years.
Step 1: Start
If No }
Step 7: Stop
Write algorithm to calculate the total and average marks of 10 students for 7 subjects.
Step 1: Start
Step 2: Subject = 1
Step 9: End
Pseudocode is essentially writing in a high-level language without worrying about the details.
Usually variable and function declarations are left out, the details of certain constructs may be
elided. For example, if you’re writing C-like pseudocode, you may ignore the details of for (),
simply writing something like:
1. for i=1 to j {
2. // code here
3. }
It’s primarily meant as a tool for programmers: a way to start writing out program logic without
immediately getting into the gritty details. Often, though, since programmers dislike waste, the
pseudocode may be placed into files commented out, and fleshed out over time. This avoids
rewriting things that have already been written in pseudocode, and is a reason to keep one’s
pseudocode close to the actual language to be used.
Structured English is meant to be used for program design, particularly when working with non-
programmers. As such, it’s not meant to be close to any particular programming language.
Structured English guides recommend keeping to simple concepts: for example, using loops even
when one might actually prefer to implement with recursion in reality. Blocks of logic are
indicated by indenting, and sometimes by surrounding them with blank lines; things like brackets
or braces are not used. Mathematical notation is generally avoided, favoring descriptive text. To
take an example from Davis and Yen’s Information System Consultant’s Handbook:
1. IF stock-on-hand is less than reorder-point
2. THEN turn on reorder-flag
3. ELSE (stock-on-hand is not less than reorder-point)
4. SO turn off reorder-flag.
Writing this in pseudocode, it would more closely resemble an actual programming language.
For example, for a C++-like pseudocode:
The latter might end up being part of the actual code of the system; the former could not.