Introduction to Structured Programming 8th Feb
Introduction to Structured Programming 8th Feb
ALGORITHMS
Terminologies
1. Programming – the process of
creating a list of instructions that
computer will use to do a certain
task.
2. Programming language – set of
special symbols/characters that can
be translated into machine readable
form [used to create programs]
3. Source program – a code of
program that has not been
translated into machine readable
form.
4. Object code – a program code that
has been translated into machine
readable form.
5. Language translator – language
processors/utility programs that
convert source code to object code.
6. Assembler – translator that
converts assembly language into
machine code
7. Interpreter - translates high level source code line-
by-line.
8. Compiler – translates the entire high level source
code to object code
Differences between interpreters &
Interpreter Compiler
compilers
•Translates one •Translates entire
statement at a time source code at once
•Takes less memory •Require more memory
•Translates each time it •Object code can be
is run stored & run as required
•Slower than compiling •Faster than translating
LEVELS OF PROGRAMMING
LANGUAGES
1. Low-level languages
2. High-level languages
LOW-LEVEL LANGUAGES
There are 2 types of low-level language:
Advantages
• No need for translation
• Execution of instructions is fast
• Economise on memory
• Can be used to develop secret codes
Disadvantages:
• Not portable – machine dependent
Advantages
• Easier to understand than machine code
• Faster to debug
• The program codes are shorter than machine
code
Disadvantages
• Machine dependent
• Needs a lot of training to understand
• Needs translation: therefore slower to execute
HIGH-LEVEL LANGUAGES
•They use a language very close to
human language.
•They are therefore very user friendly
•Are machine-independent & include:
system
• STEP 2: PROBLEM DEFINITION
• Specify objectives/users
Follow syntax
STEP 5: PROGRAM TESTING & DEBUGGING
Direct
Phased
Pilot
Review & maintenance – post
correctly.
PROGRAM DOCUMENTATION
Rules
1.Single start and stop points
2.Unambiguous statements
3.Input, processing & output operations
must be clearly depicted using keywords
4.Clearly outlined/ indented
5.Short and clear statements
ALGORITHMS
• Set of logical and finite steps that solve a specific
problem
Characteristics
1.Finiteness
2.Logically related statements
3.Clear & precise steps
4.Non-ambiguity of the statements
Delimiters – unique characters or string
that mark the start or end of a particular
statement, string or function.
C Output
•printf() is one of the main output function. The function sends formatted output to the screen. For example,
Example 1: C Output
#include <stdio.h>
int main()
{
// Displays the string inside quotations
printf(“Example of C Output");
return 0;
}