SSC Gr10 ICT Q4 Module 2 WK 2 - v.01-CC-released-7June2021
SSC Gr10 ICT Q4 Module 2 WK 2 - v.01-CC-released-7June2021
ICT
(Special Science Class)
Computer Programming
Quarter 4 - Module 2:
Testing and Debugging
1
ICT (Computer Programming) – Grade 10
Alternative Delivery Mode
Quarter 4 – Module 2: Testing and Debugging
First Edition 2021
Republic Act 8293, section 176 states that: No copyright shall subsist in any work of
the Government of the Philippines. However, prior approval of the government agency
or office wherein the work is created shall be necessary for exploitation of such work
for profit. Such agency or office may, among other things, impose as a condition the
payment of royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names,
trademarks, etc.) included in this module are owned by their respective copyright
holders. Every effort has been exerted to locate and seek permission to use these
materials from their respective copyright owners. The publisher and authors do not
represent nor claim ownership over them.
This Self-Learning Module (SLM) is prepared so that you, our dear learners, can
continue your studies and learn while at home. Activities, questions, directions,
exercises, and discussions are carefully stated for you to understand each lesson.
Each SLM is composed of different parts. Each part shall guide you step-by-step as
you discover and understand the lesson prepared for you.
Pre-tests are provided to measure your prior knowledge on lessons in each SLM. This
will tell you if you need to proceed on completing this module or if you need to ask your
facilitator or your teacher’s assistance for better understanding of the lesson. At the
end of each module, you need to answer the post-test to self-check your learning.
Answer keys are provided for each activity and test. We trust that you will be honest in
using these.
In addition to the material in the main text, Notes to the Teacher are also provided to
our facilitators and parents for strategies and reminders on how they can best help you
on your home-based learning.
Please use this module with care. Do not put unnecessary marks on any part of this
SLM. Use a separate sheet of paper in answering the exercises and tests. And read
the instructions carefully before performing each task.
If you have any questions in using this SLM or any difficulty in answering the tasks in
this module, do not hesitate to consult your teacher or facilitator.
Thank you.
What I Need to Know
These topics should serve as a link for learners to identify the essential features: how
the program works and to evaluate a program by testing and debugging using Pascal
programming language.
After going through this module, you are expected to do the following:
3. Demonstrate skills in writing and documenting programs in Pascal
programming.
3.11. Evaluate an output of a program by testing and debugging.
3.12. Explain how the program works.
What I Know
What’s In
Directions: Search for the given words in the box. Copy and encircle the word you
have found.
E P D A F G T F O R U
A R F C A B P T U F Y
D O D F F G O E G V H
S C T A G J J S P C A
G E H F U N C T I O N
B D E B U G G I N G G
B U J A T K W N M B C
T R G D G L S G H X V
E E T S H D A F A O B
S S Y N T A X X S B G
Lesson
Testing and Debugging
1
What’s New
Directions: Describe/define the following terms inside the box and come up with a
concept map to show the interrelationship between and among the different terms.
Logical
Sources of
Errors Syntactic
Semantic
What is It
Logical Errors
- are those which may not prevent a program from running but do produce
wrong results and may go undetected. Some such errors include:
Other Errors
- may also be encountered, these include:
• Misunderstanding of functions;
• Misuse of operating system; and
• Misbehavior of the computer.
Testing means verifying correct behavior. Testing can be done at all stages of module
development: requirements analysis, interface design, algorithm design,
implementation, and integration with other modules. In the following, attention will be
directed at implementation testing. Implementation testing is not restricted to execution
testing. An implementation can also be tested using correctness proofs, code tracing,
and peer reviews, as described below.
Debugging is a cyclic activity involving execution testing and code correction. The
testing that is done during debugging has a different aim than final module testing.
Final module testing aims to demonstrate correctness, whereas testing during
debugging is primarily aimed at locating errors. This difference has a significant effect
on the choice of testing strategies.
Syntax Errors
Syntax errors are the grammatical errors in a program. Every language has its own
set of rules, like creating identifiers, writing expressions, etc. for writing programs.
When these rules are violated, the errors are called syntax errors. Many
modern integrated development environments can identify the syntax errors as you
type your program. Else, it will be shown when you compile the program. Let us take
an example −
In this program, the variable prod has not been declared, which is thrown up by the
compiler.
Semantic Errors
Semantic errors are also called logical errors. The statement has no syntax errors,
so it will compile and run correctly. However, it will not give the desired output as the
logic is not correct. Let us take an example.
Look at line 13. Here, programmer wants to check if the divisor is 0, to avoid division
by 0. However, instead of using the comparing operator ==, assignment operator =
has been used. Now every time the “if expression” will evaluate to true and program
will give output as “You cannot divide by 0”. Definitely not what was intended!!
Logical errors cannot be detected by any program; they have to be identified by the
programmer herself when the desired output is not achieved.
Runtime Errors
Runtime errors are errors that occur while executing the program. This implies that the
program has no syntax errors. Some of the most common run time errors your program
may encounter are −
• Infinite loop
• Division by '0'
• Wrong value entered by user (say, string instead of integer)
Code Optimization
Any method by which code is modified to improve its quality and efficiency is
called code optimization. Code quality determines life span of code. If the code can
be used and maintained for a long period of time, carried over from product to product,
its quality is deemed to be high and it has a longer life. On the contrary, if a piece of
code can be used and maintained only for short durations, say till a version is valid, it
is deemed to be of low quality and has a short life.
PROGRAM Test;
VAR
x : REAL;
i : INTEGER;
j : INTEGER
BEGIN
x := 12.449;
i := 10;
j := -300;
WRITE('This is some text');
WRITELN(“Unformatted integer “,i);
WRITELN('Unformatted integer computation ',i*i);
WRITELN('formatted integer',i:4);
WRITELN('formatted integer,’j:4);
WRITELINE('Unformatted real ',x);
WRITE('Formatted real');
WRITE(x:8:2)
WRITELN('all in one line');
END.
OUTPUT:
What I Have Learned
What I Can Do
Testing Debugging
1. 1.
2. 2.
3. 3.
4. 4.
5. 5.
.
.
Assessment
Directions: The program below displays the value of the variable Num on the
screen. Write your output inside the box. (10pts.)
PROGRAM SixteenthProgram;
USES Crt;
VAR Num: INTEGER;
BEGIN
{This is my sixteenth program}
CLRSCR;
FOR Num :=1 TO 24 DO WRITELN(Num);
END.
https://www.tutorialspoint.com/pascal/pascal_procedures.htm
Additional Activities
16
Answer Key
E P D A F G T F O R U
A R F C A B P T U F Y
D O D F F G O E G V H
S C T A G J J S P C A
G E H F U N C T I O N
B D E B U G G I N G G
B U J A T K W N M B C
T R G D G L S G H X V
E E T S H D A F A O B
S S Y N T A X X S B G
What’s More
PROGRAM Test;
VAR
x : REAL;
i : INTEGER;
j : INTEGER;
BEGIN
x := 12.449;
i := 10;
j := -300;
WRITE('This is some text');
WRITELN('Unformatted integer ',i);
WRITELN('Unformatted integer computation ',i*i);
WRITELN('formatted integer',i:4);
WRITELN('formatted integer',j:4);
WRITELN('Unformatted real ',x);
WRITE('Formatted real');
WRITE(x:8:2);
WRITELN('all in one line');
END.
Output:
This is some text
Unformatted integer 10
Unformatted integer computation 100
formatted integer 10
formatted integer-300
Unformatted real 1.24490000000E+01
Formatted real 12.45all in one line
References:
St. Augustine Publications, Inc. 2006. Programming in Turbo Pascal the Easy
Way, pp. 149-158
https://www.tutorialspoint.com/programming_methodologies/programming_m
ethodologies_debugging.htm
https://www.slideshare.net/hidden__/pascal-tutorial?from_action=save
https://www.wisdomjobs.com/e-university/pascal-programming-tutorial-
168/errors-in-programming-7036.html
18