Topics to study for the Program Implementation Unit Test
Appropriate programming terms for the following:
Errors reported by translators when the rules of the language are not obeyed.
A program in high-level or assembly-level language.
An error in a program.
When the required results are not given by the program due to bad reasoning by the programmer.
Input values used in a program to see if it is producing the correct results.
Program instruction in each of the following types of programming languages:
High-level Language -
Machine-level language -
Assembly-level language -
4GL -
5GL -
Translator used for the following:
i. To convert HLL instructions to MLL by taking one instruction at a time.
ii. To convert ALL instructions to MLL.
iii. To convert HLL instructions to MLL by taking instructions together.
Matching Pascal program commands to the definitions:
Program Command Definition
Var Declare variables
Read Accept input
ClrScr Clears the Screen
Repeat-Until Loop Repeats the execution or a set of instructions for at least one time
WriteLn Displays input or output on the next line
End Terminates the overall running of a program
Const Declares non-variables that does not change during the execution of a
program
Program Identifies the name of the program
ReadLn Displays the data input on the next line
For Loop Repeats a set of instructions for a number of times
End Terminates a subsection of a program
Uses Crt Works in conjunction with the monitor and ClrScr
While-Do Loop This loop is executed once the condition is true
Write Displays input or output on the same line
If-Then-Else Executes the proceeding statements conditionally
Pascal statements and their types of control structures:
i. for -
ii. while -
iii. if-then-else -
iv. repeat -
v. if-then -
Four operations that can be performed on an array are read, write, traverse and search.
Below is a Pascal program using the following algorithm:
1 1
Algorithm
a. Prompt the user to enter a number.
b. Accept the value and store it in variable num.
c. Check to see if num is more than 10. If it is more than 10 add 5 to it. Otherwise multiply num by
3. Store the results in a variable Ans.
d. Display the results in Ans along with the message “the answer is”.
Pascal Program
The following shows parts of a computer program. Suppose Part A shows the program before
translation and Part B shows the program after translation.
Part A Part B
Readln(num1); 10010011011
Readln(num2); 11110011101
Sum := num1+num2; 11011010110
Writeln(sum); 11011001110
Generation or level language is Part A -
Generation or level language is Part B -
Name one translator that can be used to convert Part A to Part B -
The generic name for the program code in Part A before translation -
The generic name of the program code in Part B after translation -
A program in Pascal that will accept the values for Principal, No of Years and Interest Rate, then
calculate and display the simple interest. (Simple Interest = Principal * Years * Rate /100).
A program in Pascal that will prompt the user to enter three unequal numbers and display the
smallest among them.
A program in Pascal that will print the even numbers between 100 and 300.
2 2
A program in Pascal that will accept a number and display the multiplication table of that number
up to 20 times in the following format:
1x5=5
2 x 5 = 10
3 x 5 = 15
________
________
________
________
________
________
________
20 x 5 = 100
3 3
A program in Pascal that will accept 30 marks of students and display the number of students who
scored 80 or more, 60 -79 and below 60.
A program in Pascal that will accept the scores for 10 students, store them in a one dimensional
array and display them.
4 4