Professional Documents
Culture Documents
Batch-12 CS May QP
Batch-12 CS May QP
Instructions
Information
Advice
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
(b) State the meaning of logic. How do you understand the term logic errors
in your program? 2
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
(c) Describe the difference between local variables and global variables in a 2
computer system.
…………………………………………………………………………………………………………………………………………………………..….
…..………………………………………………………………………………………………………………………………………………………….
(d) What happens when a global variable and a local variable share the same name? 1
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………………
(i) Identify a line number where the code includes a relational operator. 1
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
(ii) Identify a line number where a variable is set to a numeric value entered by a 1
user.
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
(iii) Identify the name of a variable passed from the main program to the 1
subprogram.
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
(iv) Identify the name of a variable that receives the value calculated by the 1
subprogram.
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
(v) State the value returned by the subprogram when the input values are 2
educational, 3, 6
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
• use the library subprogram getHour () to get the hour part of the current time.
• output “Good morning” when the hour is between 3 and 12, inclusive.
• output “Good afternoon” when the hour is between 13 and 19, inclusive.
• Complete the flowchart to represent this algorithm, in the space provided on the
• next page.
The call to the library subprogram getHour () has already been included.
Use this subprogram symbol to show waiting for 1 minute. 6
Draw your flow chat here.
(b) Another algorithm determines when to change the flavored syrups for a drinks
dispensing machine.
Figure-1
(i) Give the output produced by the algorithm. 2
…………………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………….
………………………………………………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………….
………………………………………………….……………………………………..…………….…………………………………………………
(iii) State how the pseudocode needs to be changed to make this amendment. 1
…………………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………….
………………………………………………….……………………………………..…………………………….…………………………………
Write a program to display the square and cube of a number between 1 and 50
entered by a user.
Th code must:
ask the user to enter a number between 1 and 50 inclusive
• display the number, the square of the number and the cube of the number,
appropriate labels
• stop when a number outside the range 1 to 50 is entered.
Save your code as Q04FINISHED with the correct file extension for the
programming language.