0% found this document useful (0 votes)
24 views13 pages

Uter

The document contains multiple programming tasks, including the process of decomposition, flowchart creation for algorithms, and pseudocode writing. It covers various algorithms such as counting characters in a string, inputting unique integers, and handling boolean variables. Each task requires drawing flowcharts or writing pseudocode to represent the specified algorithms.
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)
24 views13 pages

Uter

The document contains multiple programming tasks, including the process of decomposition, flowchart creation for algorithms, and pseudocode writing. It covers various algorithms such as counting characters in a string, inputting unique integers, and handling boolean variables. Each task requires drawing flowcharts or writing pseudocode to represent the specified algorithms.
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/ 13

5

3 (a) The process of decomposition is often applied to a programming problem.

Describe the process of decomposition.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Result is a 1D array of type STRING. It contains 100 elements.

Draw a program flowchart for an algorithm that will output each element in the array.

[4]
© UCLES 2021 9608/23/M/J/21 [Turn over
6

(c) A program will:

• input 50 unique integer values


• output the largest value
• output the average of the values excluding the largest value.

Draw a program flowchart to represent the algorithm.

Variable declarations are not required.

It is not necessary to check that each input value is unique.

[6]
© UCLES 2021 9618/21/M/J/21
6

(c) A program will:

• input 50 unique integer values


• output the largest value
• output the average of the values excluding the largest value.

Draw a program flowchart to represent the algorithm.

Variable declarations are not required.

It is not necessary to check that each input value is unique.

[6]
© UCLES 2021 9618/23/M/J/21
4

2 (a) An algorithm will:

1. input an integer value


2. jump to step 6 if the value is zero
3. sum and count the positive values
4. sum and count the negative values
5. repeat from step 1
6. output the two sum values and the two count values.

Draw a program flowchart on the following page to represent the algorithm.

Note that variable declarations are not required in program flowcharts.

© UCLES 2021 9618/22/O/N/21


5

[5]
© UCLES 2021 9618/22/O/N/21 [Turn over
4

2 (a) The following pseudocode algorithm counts the number of each alphabetic character in the
string Msg. The character count values are stored in an array CharCount.

Variable declarations are not shown.

FOR Index 1 TO 26
CharCount[Index] 0
ENDFOR

FOR Index 1 TO LENGTH(Msg)


ThisChar MID(Msg, Index, 1)
ThisChar LCASE(ThisChar)
IF ThisChar >= 'a' AND ThisChar <= 'z'
THEN
ThisIndex ASC(ThisChar) – 96 // value from 1 to 26
CharCount[ThisIndex] CharCount[ThisIndex] + 1
ENDIF
ENDFOR

© UCLES 2021 9608/21/M/J/21


5

Draw a program flowchart to represent the algorithm.

Variable declarations are not required in program flowcharts.

[5]

© UCLES 2021 9608/21/M/J/21 [Turn over


4

2 Study the following pseudocode.

DECLARE Overload : BOOLEAN

PROCEDURE LEM()

DECLARE Status : BOOLEAN


DECLARE Landed : INTEGER

Overload FALSE
Landed FALSE

WHILE Landed = FALSE


Status Sample()
IF Status = TRUE
THEN
Landed SubA(42)
ELSE
Overload SubB(37)
IF Overload = TRUE
THEN
CALL Display("Alarm 1202")
ENDIF
ENDIF
ENDWHILE

ENDPROCEDURE

(a) Examine the pseudocode and complete the following table:

Answer

The identifier name of a global variable

The name of the loop structure

The identifier involved in a data type mismatch

The name of a procedure that takes a parameter

The name of a function

[5]

© UCLES 2021 9608/22/M/J/21


5

(b) Draw a program flowchart to represent the pseudocode algorithm.

Variable declarations are not required in program flowcharts.

[5]
© UCLES 2021 9608/22/M/J/21 [Turn over
6

(b) The program flowchart shown describes a simple algorithm.

START

Set Count to 1

Set Flag to FALSE

Is Flag = YES
FALSE AND
Count <= 5 ?

NO
ReBoot()

Set Count to Count + 1

Set Flag to Check()

Is Flag = YES
FALSE ?

NO
Alert(27)

END

© UCLES 2021 9618/23/O/N/21


7

Write pseudocode for the simple algorithm shown on page 6.

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

............................................................................................................................................................ [6]

© UCLES 2021 9618/23/O/N/21 [Turn over


6

(c) The program flowchart for part of an algorithm from a mobile phone program is shown.
Identifier Active is a global variable of type BOOLEAN.

START

Set Online to FALSE

Is Online = NO
FALSE ?

YES END

Is Active = NO
TRUE ?

YES
CALL Reset()
CALL Sync()

Is Active = YES
FALSE ?

NO
CALL Error("No
Signal")

Set Online to TRUE

CALL ReCheck()

© UCLES 2021 9608/23/M/J/21


7

Write pseudocode to implement the algorithm represented by the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 9608/23/M/J/21 [Turn over

You might also like