0% found this document useful (0 votes)
5 views

Programming Fundamentals

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Programming Fundamentals

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

1-1

PROGRAMMING
FUNDAMENTALS

DR. F. O. BOATENG
Contents 1-2

1. Introduction
2. Algorithm
3. Flowchart
4. Pseudocode
Introduction 1-3

 Programming is the process of designing


writing computer code to create a program,
in order to solve a problem.
 Programs consist of a series of instructions
to tell a computer exactly what to do and
how to do it.
Introduction 1-4

 Programming involves the use of the


following tools
• Algorithm
• Flowchart
• Pseudocode
• Programming Language
Algorithm 1-5

 An algorithm is a sequence of steps


required to solve a problem.
 Itis a list of well-defined instructions to
solve a problem
Algorithm 1-6

 Analgorithm has the following


characteristics:
• It ends after a fixed number of steps.
• Each step in clearly specifies the action
to be performed.
• The steps specify basic operations.
• These operations could include
calculations, input/output operations and
comparisons
Algorithm 1-7

 Analgorithm has the following


characteristics (Cont.):
• It accepts input data, in a defined format,
before it can be processed.
• It generates one or more outputs after
the input is processed.
Algorithm 1-8

For example, to withdraw a required amount


from an ATM, the algorithm will be:
Algorithm 1-9

 For example, to withdraw a required amount


from an ATM, the algorithm will be:
Step1: Start the algorithm
Step 2: Go to any local ATM
Step 3: Insert/swipe your ATM card.
Step 4: Press the language button that you
want to choose
Step 5: Enter the pin code number
Step 6: Press the account type
(savings/current) button from which you want
to withdraw the money
Algorithm 1-10

Step 7: press the cash withdrawal button


Step 8: enter the amount you want to withdraw.
Step 9: collect the amount from the ATM
machine.
Step 10: collect the statement from the ATM
machine
Step 11: collect your ATM card
Step 12: End the algorithm

Consider another algorithm that displays


the product of two numbers
Algorithm 1-11

 Try
for example, consider another algorithm
that displays the product of two numbers:
Algorithm 1-12

 Analgorithm that displays the product of


two numbers:
Step 1: Start the algorithm
Step 2: Get the first number
Step3: Get the second number
Step 4: Multiply the two numbers
Step 5: Display the result
Step 6: End the algorithm
Flowchart 1-13

A flowchart is a graphical representation


of an algorithm.
 It consists of a set of symbols.
 Each symbol represents a specific kind of
activity depicted in the algorithm.
Flowchart 1-14

Advantages of flowchart
 Flowcharts help in analyzing the problems
effectively.
 Flowcharts
act as a guide during the
program development phase.
 Flowcharts help easy debugging of logical
errors.
Flowchart 1-15

Disadvantages of Flowchart
Alengthy flowchart may extend over
multiples pages, which reduces readability.
 Drawing a flowchart using any graphical
tool is a time consuming process.
 Thechanges made to a single step may
cause redrawing the entire flowchart.
Flowchart
 Symbols used in constructing flowchart
Input/output

Processing

Output

Decision – contains a condition


Flowchart
 Symbols used in constructing flowchart (Cont.)

Procedure/Subroutine

Flow lines

Initiator/terminator

On page connector
Flowchart
 Symbols used in constructing flowchart (Cont.)

Off page connector

Annotation
This is used to insert comments in a flowchart
Flowchart
 Let us see an example flowchart where a number
is accepted and incremented by 1 and the result is
displayed
Pseudocode
 Pseudocode is a detailed yet readable description of
what an algorithm must do, expressed in a formally
styled natural language rather than in a programming
language
 It is fake code used as a model for programs
 It has no syntax rules
 It is easy and fast to write as it uses English like
statements
 It needs no rewriting if any changes are made in the
steps.
 This is because each step is written independent of
the other.
 It can be converted to a program by using any
programming language.
Pseudocode
Limitations of Pseudocode
 Pseudocode does not provide a graphical
representation of an algorithm; therefore, it
might be difficult to understand the complex
logic in a pseudocode
 Pseudocode depicting too many nested
conditions may be difficult to understand
Limitations of
pseudocode
 Pseudocode does not provide a graphical
representation of an algorithm; therefore, it
might be difficult to understand the complex
logic in a pseudocode
 Pseudocode depicting too many nested
conditions may be difficult to understand
Keyword Usage

// Represents a comment entry.

begin All the steps of the pseudocode are


…. written between the begin….end block.
end
The first statement in a pseudocode is a
begin statement and the last statement
is an end statement.

Accept/ Is used to accept input. For example, to


input accept the name of the user, the
following statement can be used:
accept username
Compute Is used to calculate the result of an
expression.
For example, to calculate the sum of two
numbers, the following statement can be
used: Compute sum as 10+30
Display Is used to display output.
For example, to display the message
‘welcome to my kingdom’ on the
screen, the following statement can be
used:
display ‘welcome to my kingdom’
if…else This is referred to as a decision construct.
The is used when, depending upon a
condition, different actions may have to
be taken.
Repeat This is an iterative construct with a
….until testing statement at the bottom of the
iterative set of statements.
While This is an iterative construct with a
testing statement at the top of the
iterative set of statements

For(; ;) It is an iterative construct in which a


variable is initialized, incremented,
and an expression is tested in the
same line.
Call Is used to invoke subroutines,
subroutin subprograms, or a procedure that is
e_name specified by subroutine_name.
1-26

THANK
YOU

You might also like