0% found this document useful (0 votes)
42 views1 page

Worksheet #1 - Function and Procedure

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Worksheet #1 - Function and Procedure

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

Beaconhouse School System

Jauhar Campus
Worksheet
Student Name: _________________________________
Class/Sec:_____________
Topic: Function and Procedure Date:
____________________

Q1. (a) A programmer is developing an algorithm to solve a problem. Part of the algorithm
would be appropriate to implement as a subroutine (a procedure or a function).
(i) State two reasons why the programmer may decide to use a subroutine.
(ii) A procedure header is shown in pseudocode:
PROCEDURE MyProc(Count : INTEGER, Message : STRING)
Give the correct term for the identifiers Count and Message and explain their use.
Term ..................................................................................................................................
....................
Use ....................................................................................................................................
....................

Q2. A procedure Count() will:


1. input a value (all values will be positive integers)
2. count the number of odd values and count the number of even values
3. repeat from step 1 until the value input is 99
4. output the two count values, with a suitable message.
The value 99 must not be counted.
Write pseudocode for the procedure Count().

Q3. Write a function called SquareNumber that:


● Accepts one integer number as a parameter
● Returns the square of that number
Using this function, write pseudocode to:
1. Input a number from the user
2. Call the function to calculate its square
3. Output the result

Q3. Write a function called CalculateAverage that:


● Accepts three integer marks as parameters
● Returns the average of the three marks
Using this function, write pseudocode to:
1. Input three marks from the user
2. Call the function to calculate the average
3. Output the average

Q6. A school wants a program that:


1. Has a function IsPass(mark) which returns TRUE if mark ≥ 50, otherwise FALSE.
2. Has a procedure CheckStudent() which:
○ Inputs a student’s mark
○ Calls IsPass
○ Outputs "Pass" or "Fail"
Write pseudocode for both the function and the procedure.

You might also like