Section 11: Programming Techniques; The Problem Statement; The Algorithm - HP -11C Owner's Handbook Manual

Hide thumbs Also See for HP-11C:
Table of Contents

Advertisement

Section 11
Programming Techniques
Structure
What we mean by "structure" is the notion that even in a language
as far from English as the HP-11C programming language there
can be organization. We want you to realize that the programs you
run on the HP-11C can be both useful and "friendly". Butit is up to
you, the programmer, to make them that way. What is involved is a
little forethought and planning to make your programs efficient,
readable and correctable. This section is a compilation of
techniques and examples that we hope will aid you in writing such
programs.
The Problem Statement
The first step involved in writing a program is stating the problem
to be solved. This may seem an obvious step, but often it is
completely omitted. The programmer then finds that the program
does not produce the desired results because the original objective
was not clear. This first step is always important because it gives
both a clear idea of the problem and a definite direction to its
solution. It is only then that one can start the logical development
of the program.
Example: Suppose we wantto find the roots of the equation ax? +
bx + ¢ =0, where a, b and ¢ are constants. Our problem statement
might then be: "With inputs of a, b and ¢, find both solutions to the
equation ax?+ bx +¢=0."
Again, such a statement may seem obvious, but it supplies the two
fundamental quantities: 1) the data we must supply and 2) the
output we desire. With these two essentials and the concept of a
solution we can go on to the second step, that of designing the
algorithm.
The Algorithm
An algorithm is not a program, but an outline of the logical steps
required to solve the problem. Such an algorithm should be non-
specific at first, solving the problem through logical steps but
206

Advertisement

Table of Contents
loading

Table of Contents