Programming_Quiz
Programming_Quiz
Programming Quiz 1
Name: ……………………………………..……………………………………..
1 Write down the most appropriate data type for the following examples:
[3]
2 The variables Number1, Number2, Number3 are used to store numbers to be entered by the
user.
……………………………………………………………………………………………………………………………………
Declare Number1,Number2,Number3, Sum, Average :REAL
//entering the numbers
……………………………………………………………………………………………………………………………………
Output "Enter 3 numbers"
……………………………………………………………………………………………………………………………………
Input Number1, Number2 , Number3
……………………………………………………………………………………………………………………………………
//Calculating the sum and average
Sum <--- Number1+ Number2 + Number3
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
//outputting the answers
Output "The sum is ",Sum
……………………………………………………………………………………………………………………………………
Output "The average is ", Average
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
Eng. Omar El Sa,y OL Computer Science
[5]
3 Write a program using pseudocode that takes from the user a student mark in an exam and
the program should calculate and output the percentage.
Output Invalid mark if the user entered a negative number or a number greater than 25
Input Mark
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
//calculating that the mark should not be over or under
……………………………………………………………………………………………………………………………………
IF Mark >25 OR Mark <0 THEN
Output "Invalid Mark"
……………………………………………………………………………………………………………………………………
Else
……………………………………………………………………………………………………………………………………
Percentage <--- (Mark/25) * 100
……………………………………………………………………………………………………………………………………
//calculated the percentage
Output "Percentage = ",Percentage [5]
ENDIF
Eng. Omar El Sa,y OL Computer Science
ENDIF
……………………………………………………………………………………………………………………………………
ENDIF
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………
[6]
Eng. Omar El Sa,y OL Computer Science
5 State the output of the following program if the value stored in Number1 is 4 and the value
stored in Number2 is 5
ENDIF
………………………………………………………………………………………………………………………………[1]
-The larger number is 5
6 The following program should display Valid if the weight is greater than or equal to 0 and
display Invalid otherwise.
lines 4,6
an output statement ……………………………………………………………………………………………………….
[3]
There are two errors in the code.
(b) Identify the two errors in the pseudocode and suggest corrections.
line 3
Error 1 …………………………………………………………………………………………………………………………
should be IF Weight >=0 THEN
……………………………………………………………………………………………………………………………………
Line 2
Error 2 …………………………………………………………………………………………………………………………
[2]