TOOLS FOR PROGRAMMING • The design of a solution to a problem results in the creation of a program. It is the program (resulting from the use of an appropriate programming language’s syntax) that the user runs or uses to address his problem. • In the process of designing the solution or creating the program, the programmer uses programming tools to represent his logical steps to be undertaken to achieve the desired objective. • The following are some of the programming tools that are invariably used for program design and documentation: • Algorithms • Pseudocode • Flowchart
WHAT IS AN ALGORITHM? • An algorithm is a written list or description of the solution to a particular problem. It is a finite, step-by-step list of well defined instructions for solving a particular problem. Thus: Each step must be well defined – must not be ambiguous The process must halt in a finite number of step, and finally, The process must do what is claimed – it must solve the problem being addressed. • In the simplest form, it could be single step of a mathematical expression of a solution. For example, the algorithm for solving the quadratic equation a𝔁2 + b𝔁 + c, is simply expressed as −𝑏± 𝑏2 −4𝑎𝑐 𝒳 1,2 = 2𝑎 where a ≠ 0 (and b2 ≥ 4ac for real roots) Abiew Nuku Atta Kordzo (Systems Analysis: 2016) - GTUC WHAT IS A PSEUDOCODE? • It is a human-language like programmer’s shorthand outlining the logical steps a module must follow or perform, (without commas or any exact syntax) in order to solve a problem or address a particular module in a bigger program.
• For an English speaking country like ours, it is an English like step-by-
step process describing logically how to carry out a specific task, but not following any particular syntax. •
WHAT IS A PROGRAM FLOWCHART? • It is a graphical representation of the logical steps to taken in solving a problem. Flowchart symbols are specific shapes used to create a visual representation of a program.
• It is basically a collection of standard symbols and lines:
Boxes indicate what is to be done Lines indicate the sequence of the boxes Arrowheads on the lines indicate the direction of a program flow.
PSEUDOCODE PRESENTATION 1. Start 2. Open area calculation module 3. Enter values for L and B 4. If L or B invalid, re-enter values 5. Else calculate Area 6. Display values of L, B and A 7. End if 8. End
ALGORITHM PRESENTATION 1. Read/Input values for L and B 2. Validate values for L and B 3. If either L or B is invalid go to step 1 4. Calculate Area A using formula A = L * B 5. Print values for L, B and A 6. Stop
Exercise • Present algorithm, pseudocode and flowchart on the following • Area of triangle • Area of circle • Body Mass Index • Density of an object • Use an algorithm or flowchart to outline how, in one program, you will determine the area, diagonal or perimeter of any rectangle of length L, and breadth B, for as many times as it desired.