0% found this document useful (0 votes)
16 views4 pages

Exam Style Questions 1

The document contains exam preparation questions focused on programming concepts, including data types, code output, error identification, test data examples, and logical operators. It also includes tasks related to program design, variable declaration, conditional loops, and code efficiency improvements. Additionally, it requires writing code for generating random numbers and handling user input.

Uploaded by

17naiaar01
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)
16 views4 pages

Exam Style Questions 1

The document contains exam preparation questions focused on programming concepts, including data types, code output, error identification, test data examples, and logical operators. It also includes tasks related to program design, variable declaration, conditional loops, and code efficiency improvements. Additionally, it requires writing code for generating random numbers and handling user input.

Uploaded by

17naiaar01
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
You are on page 1/ 4

Exam Prep Questions (46 Marks)

1. State the most suitable data type for storing the following items: (3)
a. Post code
b. Yes or No response
c. Price of an item

2. State the output from the following code: (3)


a. LINE 1 DECLARE price INITIALLY 1.99
LINE 2 DECLARE quantity INITIALLY 5
LINE 3 SET total TO price * quantity
LINE 4 SEND total TO DISPLAY

b. LINE 1 DECLARE numPupils INITIALLY 20


LINE 2 DECLARE total INITIALLY 160
LINE 3 SET average TO total / numPupils
LINE 4 SEND average TO DISPLAY

c. LINE 1 DECLARE first INITIALLY 3


LINE 2 DECLARE second INITIALLY 2
LINE 3 SET third TO first ^ second
LINE 4 SEND third TO DISPLAY

3. Read the code below and identify the type of error in each one and rewrite the code to show
how to fix the error: (6)

a. LINE 1 DECLARE age INITIALLY “”


LINE 2 RECEIVE age FROM keyboard
LINE 3 SND “Your age is : & age TO DISPLAY

b. LINE 1 DECLARE price INITIALLY 1.99


LINE 2 RECEIVE quantity FROM keyboard
LINE 3 SET total TO price / quantity

c. LINE 1 DECLARE price INITIALLY 1.99


LINE 2 SET total TO price * quantity
LINE 3 RECEIVE quantity FROM keyboard

d. LINE 1 DECLARE cost as “”


LINE 2 SET total TO cost ^ 2
LINE 3 SEND “The total is “ & total TO DISPLAY

4. A program is required to take in the number of items available for sale on a garden centre
website. The minimum number is 0 and the maximum number in stock of any product is 25.
Give an example of normal, extreme and exceptional test data for this program. (3)
5. A program is required to ensure that a user can only enter a minimum car speed of 0mph
and maximum speed of 75mph. If a speed is entered below or above this speed then an
error message should be displayed. Using a design technique of your choice, design an
efficient solution to ensure that the program will only accept valid speeds from the user. (4)

6. Complete the table below. The first one has been done for you (3):

Example Construct
Total = 0.0 Assigning value to a variable
airportCode & country & airline
If population > 100000 then
New = Round(number, 2)

7. Identify the logical operators and/or arithmetic operators in the following code: (3)

a. IF age > 13 AND age < 18 THEN

Msgbox(“You are eligible for a discounted ticket”)

END IF

b. IF userPassword = NOT(correctPassword) THEN


Msgbox(“Incorrect – try again)
Attempts = attempts + 1

END IF

8. Look at the program design below and identify the following:

a. Input (1)
b. Process (1)
c. Output (1)
d. Standard algorithm used (1)
get months
from user

e. Type of loop used (1)


Repeat until
between 0
months is
and 12
0 and 12?
between
months

PROBLEM:
Sunshine
message
“invalid”
Display

Display “valid”
message
9. Look at the code below and identify the following:

Line 1 Dim months As Integer

Line 2 Do

Line 3 months = InputBox("How many months had 10 days of sunshine?")

Line 4 If months < 0 Or months > 12 Then

Line 5 MsgBox("Please enter a valid number of months")

Line 6 End If

Line 7 Loop Until months >= 0 And months <= 12

Line 8 txtOutput.AppendText("Thank you. That is valid")

a. Line containing a complex condition (1)


b. Line declaring a variable (1)
c. Line with user output (1)
d. Line containing a conditional loop (1)

10. Rewrite the following lines of code in a more efficient way (6):

a. IF finalCost <= 100 THEN


Discount = finalCost – 10

END IF

IF finalCost > 101 THEN

Discount = fincalCost – 25

END IF

b. Age(0) = Inputbox(“Please enter your age”)


Age(1) = Inputbox(“Please enter your age”)
Age(2) = Inputbox(“Please enter your age”)
Age(3) = Inputbox(“Please enter your age”)
Age(4) = Inputbox(“Please enter your age”)

11. Write the code to do the following:


a. Generate a random number between 1 and 15 (2)
b. Store the length of a user’s password in a variable called passwordLength (2)
c. Round the variable average test score to 1 decimal place (2)

You might also like