0% found this document useful (0 votes)
22 views29 pages

Lesson 5 Basic Computer Programming

The document provides information about basic computer programming and algorithms. It includes: 1) An introduction to basic computer programming concepts like the programming cycle, algorithms, flowcharts, and the input-process-output model. 2) Explanations and examples of each step in the programming cycle - problem definition, problem analysis, algorithm development, coding and documentation, testing and debugging, and maintenance. 3) Descriptions of different types of errors like syntax errors, runtime errors, and logical errors. 4) Examples of algorithms and how they are represented with a step-by-step process like baking a cake.

Uploaded by

rhallazgo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views29 pages

Lesson 5 Basic Computer Programming

The document provides information about basic computer programming and algorithms. It includes: 1) An introduction to basic computer programming concepts like the programming cycle, algorithms, flowcharts, and the input-process-output model. 2) Explanations and examples of each step in the programming cycle - problem definition, problem analysis, algorithm development, coding and documentation, testing and debugging, and maintenance. 3) Descriptions of different types of errors like syntax errors, runtime errors, and logical errors. 4) Examples of algorithms and how they are represented with a step-by-step process like baking a cake.

Uploaded by

rhallazgo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link] workshop.

css

1
2
3 Lesson ‘5’ {
4
5
6
[BASIC COMPUTER PROGRAMMING]
7
8
9 <MODULE 1: Algorithm and Flowchart>
10
11
12
13
}
14

Programming Language
[Link] [Link]

1 Learning Objectives; {
2
3
4
5 ‘At the end of this lesson, the
6 students should be able to:’
7 <p>
8 Enumerate steps in the programming
9 cycle
10
Identify IPO using a set of computing
11
12
problems
13 </p>
14 }
Programming Language
[Link] [Link]

1 TOPIC 1: ‘THE PROGRAMMING CYCLE’;


2
3 The computer basically is a problem
4 solving tool. Once it is provided with a
5
valid program, the computer becomes self-
6
7
operational, that is, it requires no
8 human intervention during processing.
9 The program development life cycle is a
10 set of steps or phases that are used to
11
develop a program in any programming
12
13 language.
14

Programming Language
[Link] [Link]

1 TOPIC 1: ‘THE PROGRAMMING CYCLE’;


2
3
4
5
6
7
8
9
10
11
12
13
14

Programming Language
[Link] [Link]

1 1: ‘Problem Definition’;
2
3
In this phase, we define the problem
4 statement and we decide the boundaries of
5 the problem.
6 In this phase we need to understand the
7
problem statement, what is our
8
9
requirement, what should be the output of
10 the problem solution.
11 These are defined in this first phase of
12 the program development life cycle.
13
14

Programming Language
[Link] [Link]

1 IPO ‘Input-Process-Output’;
2
3
The input–process–output (IPO) model is a
4 widely used approach in systems analysis
5 and software engineering for describing
6 the structure of an information
7
Processing program or another process.
8
9
Many introductory programming and systems
10 analysis texts introduce this as the most
11 basic structure for describing a process.
12
13
14

Programming Language
[Link] [Link]

1 IPO ‘Input-Process-Output’;
2
3
4
5
6
7 INPUT PROCESS OUTPUT
8
9
10
11
12
13
14

Programming Language
[Link] [Link]

1 Example ‘Input-Process-Output’;
2
3
Write a program that reads in radius of a
4 circle, computes the area of circle using
5 the formula A=πr2 , and then display the
6 area of circle.
7
To define the problem, therefore the
8
9
following are identified:
10 I - Radius of the circle
11 P - Compute the area of a circle using
12 the formula A=πr2
13
O - Display the area of the circle
14

Programming Language
[Link] [Link]

1 2: ‘Problem Analysis’;
2
3
In phase 2, we determine the requirements
4 like variables, functions, etc. to solve
5 the problem.
6 That means we gather the required
7
resources to solve the problem defined in
8
9
the problem definition phase.
10 We also determine the bounds of the
11 solution.
12
13
14

Programming Language
[Link] [Link]

1 3: ‘Algorithm Development’;
2
3
During this phase, we develop a step by
4 step procedure to solve the problem using
5 the specification given in the previous
6 phase. This phase is very important for
7
program development.
8
9
That means we write the solution in step
10 by step statements.
11
12
13
14

Programming Language
[Link] [Link]

1 4: ‘Coding & Documentation’;


2
3
This phase uses a programming language to
4 write or implement the actual programming
5 instructions for the steps defined in the
6 previous phase.
7
In this phase, we construct the actual
8
9
program.
10 That means we write the program to solve
11 the given problem using programming
12 languages like C, C++, Java, etc.,
13
14

Programming Language
[Link] [Link]

1 5: ‘Testing & Debugging’;


2
3
During this phase, we check whether the
4 code written in the previous step is
5 solving the specified problem or not.
6 That means we test the program whether it
7
is solving the problem for various input
8
9
data values or not.
10 We also test whether it is providing the
11 desired output or not.
12
13
14

Programming Language
[Link] [Link]

1 6: ‘Maintenance’;
2
3
During this phase, the program is
4 actively used by the users. If any
5 enhancements found in this phase, all the
6 phases are to be repeated to make the
7
enhancements.
8
9
That means in this phase, the solution
10 (program) is used by the end-user.
11
12
13
14

Programming Language
[Link] [Link]

1 6: ‘Maintenance’;
2
3
If the user encounters any problem or
4 wants any enhancement, then we need to
5 repeat all the phases from the starting,
6 so that the encountered problem is solved
7
or enhancement is added.
8
9
10
11
12
13
14

Programming Language
[Link] [Link]

1 Types of ‘Errors’ {
2
3
4 01 Syntax Errors
< An Error encountered during compilation process. A
5 statement(s) in the source code that does not follow the
6 correct format Example: [Link] instead of typing
7 [Link](coding error)>
8 02 Run Time Error
< an error detected during execution of the
9
source code >
10
11 03 Logical Error
12
13
14 } < An error encountered when the source
code does solve the problem thus the
output of the program is not correct
Example: 2+2 = 3; (it runs but did not
Programming Language
do the expected outcome. >
[Link] [Link]

1 [Link] (“Algorithm”);
2
3
An algorithm is a set of step-by-step
4 procedures, or a set of rules to follow,
5 for completing a specific task or solving
6 a particular problem.
7
The word algorithm was first coined in
8
9
the 9th century. Algorithms are all
10 around us.
11
12
13
14

Programming Language
[Link] [Link]

1 [Link] (“Algorithm”);
2
3
Common examples include: the recipe for
4 baking a cake, the method we use to solve
5 a long division problem, the process of
6 doing laundry, and the functionality of a
7
search engine are all examples of an
8
9
algorithm.
10 Here’s what baking a cake might look
11 like, written out as a list of
12 instructions, just like an algorithm:
13
14

Programming Language
[Link] [Link]

1 [Link] (“Algorithm”);
2
1. Preheat the oven
3
2. Gather the ingredients
4
5
3. Measure out the ingredients
6 4. Mix together the ingredients to make the
7 batter
8 5. Grease a pan
9 6. Pour the batter into the pan
10 7. Put the pan in the oven
11 8. Set a timer
12 9. When the timer goes off, take the pan out of
13 the oven
14
10. Enjoy!
Programming Language
[Link] [Link]

1 [Link] (“Algorithm”);
2
3 Just as how we did with the steps in
4 making cake, computer programming do this
5 by creating an algorithm or steps on how
6
to create the program.
7
8
9
10
11
12
13
14

Programming Language
[Link] [Link]

1 [Link] (“Flowchart ”);


2
3
Flowchart is a graphical representation
4 of an algorithm. Programmers often use it
5 as a program-planning tool to solve a
6 problem.
7
It makes use of symbols which are
8
9
connected among them to indicate the flow
10 of information and processing.
11 The process of drawing a flowchart for an
12 algorithm is known as “flowcharting”.
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Terminal(Stop/Start)”);
2
3
4
5
6
7
8
9 Represents the start and the end of a
10
11 flowchart.
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Input/Output”);
2
3
4
5
6
7
8
9 Used for input and output operation.
10
11
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Flowlines”);
2
3
4
5
6
7
8
9 Indicates the flow of logic by
10
11 connecting symbols.
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Processing”);
2
3
4
5
6
7
8
9 Used for arithmetic operations and
10
11 data-manipulations.
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Decision”);
2
3
4
5
6
7
8
9 Used for decision making between two
10
11 or more alternatives.
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“On-page Connector”);


2
3
4
5
6
7
8
9 Used to join different flowline
10
11
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1 [Link] (“Off-page Connector”);


2
3
4
5
6
7
8
9 Used to connect the flowchart portion
10
11 on a different page.
12
13
14

Programming Language
Basic Symbols used in Flowchart
[Link] [Link]
Designs

1
[Link] (“Predefined Process/Function”);
2
3
4
5
6
7
8
9 Represents a group of statements
10
11 performing one processing task.
12
13
14

Programming Language
[Link] [Link]

1
2

Thank {
3
4
5
6
7
8
9
You;
10
11
12
13 }
14

Programming Language

You might also like