0% found this document useful (0 votes)
25 views2 pages

Flowchart For CASE

The document describes a navigation program function called CheckCourse() that takes a real value, Course, and returns an integer value, Adjust. It utilizes a local variable Check to determine the course deviation and adjusts the return value based on specified conditions using a CASE statement. The function also calls an Alert() procedure if the deviation does not fall within the defined ranges.

Uploaded by

bye3552
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)
25 views2 pages

Flowchart For CASE

The document describes a navigation program function called CheckCourse() that takes a real value, Course, and returns an integer value, Adjust. It utilizes a local variable Check to determine the course deviation and adjusts the return value based on specified conditions using a CASE statement. The function also calls an Alert() procedure if the deviation does not fall within the defined ranges.

Uploaded by

bye3552
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/ 2

6

3 A navigation program includes a function, CheckCourse(). This function is called with a real
value, Course, and returns an integer value.

The identifier table and the program flowchart for the function are shown as follows:

Identifier Type Description


Course REAL The value passed to CheckCourse()
Adjust INTEGER The value returned by CheckCourse()
Check INTEGER A local variable
A function that is passed a REAL value representing the
Deviate() FUNCTION course and returns a REAL value representing the current
deviation
Alert() PROCEDURE A procedure that generates a warning

START

Set Check to integer


value of
Deviate(Course)

Set Adjust to 255

CASE OF
Check
–20 to –1
OTHERWISE Set Adjust to 10

0
Set Adjust to 0

Alert()

1 to 20
Set Adjust to –10

RETURN Adjust

END

© UCLES 2020 9608/22/M/J/20


9608/22 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

3 FUNCTION CheckCourse(Course : REAL) RETURNS INTEGER 7


DECLARE Adjust, Check : INTEGER

Check ← INT(Deviate(Course))
Adjust ← 255

CASE OF Check
-20 to -1: Adjust ← 10
0 : Adjust ← 0
1 to 20 : Adjust ← -10
OTHERWISE CALL Alert()
ENDCASE

RETURN Adjust

ENDFUNCTION

1 mark for each of the following:

1 FUNCTION heading and ending including parameter as given above


2 Assign value to Check using integer conversion and intialise Adjust to
255
3 CASE ... ENDCASE
4 Conditions −20 to −1 and 1 to 20 (and corresponding assignments)
5 Condition 0 (and corresponding assignment)
6 OTHERWISE
7 Return Adjust

© UCLES 2020 Page 6 of 15

You might also like