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

May 23 Q13

A program simulates rolling 3 dice 7 times and storing the results in a 2D array called DICEDIAL. The document provides (a) pseudocode to calculate the sum of all values in DICEDIAL, (b) pseudocode for a subprogram to check for repeated numbers in a given row of DICEDIAL and return the repeated number or 0, and (c) pseudocode for a subprogram to find the highest row total in DICEDIAL and the indexes of rows with that total.
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)
95 views1 page

May 23 Q13

A program simulates rolling 3 dice 7 times and storing the results in a 2D array called DICEDIAL. The document provides (a) pseudocode to calculate the sum of all values in DICEDIAL, (b) pseudocode for a subprogram to check for repeated numbers in a given row of DICEDIAL and return the repeated number or 0, and (c) pseudocode for a subprogram to find the highest row total in DICEDIAL and the indexes of rows with that total.
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/ 1

–7– 2223 – 7011

14. A program is developed to simulate the roll of dice in a game.

Three dice are thrown, with faces that have numbers from 1 to 6.

The dice are thrown seven times, and the data are stored in a two-dimensional array called
DICEDIAL (see Figure 2).

Figure 2: The example data stored in the DICEDIAL array

[0] [1] [2]

[0] 4 2 2
[1] 4 4 4
[2] 5 2 3
[3] 6 5 5
[4] 5 5 6
[5] 1 1 4
[6] 3 2 1

(a) Construct an algorithm in pseudocode to calculate the sum of all values stored in the
DICEDIAL array. [3]

The sub-program DuplicateNum(DICEDIAL,R) checks whether there are repeated


numbers in row R. If the numbers are not repeated, it returns 0, otherwise it returns the
repeated number.

The DuplicateNum() sub-program will produce the following from the values used in Figure 2:

DuplicateNum(DICEDIAL,0) returns 2

DuplicateNum (DICEDIAL,1) returns 4

DuplicateNum(DICEDIAL,2) returns 0

(b) Construct an algorithm in pseudocode for the sub-program DuplicateNum(DICEDIAL,R).[4]

The sub-program highestRT(DICEDIAL) accepts the DICEDIAL array and outputs the
highest row total and the indexes of all the rows with that total.

From the example data given in Figure 2, highestRT(DICEDIAL) would output that the
highest row total is 16, and it occurs in the rows with indexes 3 and 4.

(c) Construct an algorithm in pseudocode for the sub-program highestRT(DICEDIAL).[8]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy