Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

December 1999
CP103: COMPUTER PROGRAMMING

SECTION A [40 Marks]

Click here to access other sections
Section B
Front Cover

SUGGESTED SOLUTIONS
Solutions and allocated marks are indicated in green.
Return to Section A (Questions)

Answer ALL questions in this section

 

1. For each of the following stages of the System Life Cycle, give two notations that are used during the stage:

a) System Analysis [2]

Any two of the following:
-System flow chart [do not accept "flowchart"] [1]
-System run chart [1]
-Data flow diagram (DFD) [1]
-Data Dictionary [1]
-Data Model [1]
-Structured chart [1]
[max 2]

b) Program Design [2]

Any two of the following:
-Jackson Structured Programming (JSP) [1]
-Pseudocode [1]
-Program flow chart [accept "flowchart"] [1]
-Decision table [1]
-Data structure diagram [1]
[max 2]

.

[4]
2. State whether each of the following statements is True or False:

a) A procedure must always return one or more values to the calling module or program. [1]

False

b) Variable parameters are not changed by the procedures which use them [1]

False

c) Local variables can only be accessed by the procedures that declare them [1]

True

d) A linked list implemented using pointers is an example of a static data structure where the size of the data structure can change as the program runs [1]

False

e) Elements in an array are accessible only through their indexes/subscripts [1]

True

 

[5]
3. The following segment of pseudocode is intended to show the logic of the Improved Bubble Sort algorithm. Flag is a boolean variable that is used to control the number of passes taking place. Once all the items are sorted, the sorting process will terminate.

State what values - either true or false - should be used in locations (a), (b), (c) and (d). [4]

DO
   SET flag to (a)
   WHILE flag is (b)
       SET flag to (c)
       FOR i = 1 to N - 1
            DO
                IF item[i]>item[i+1] THEN
                    DO
                         Swap the value of the two items
                         SET flag to (d)
                    ENDDO
                ENDIF
           ENDDO
ENDDO

a) True [1]
b) True [1]
c) False [1]
d) True [1]

 

[4]
4.

a) The following fragment of JSP is not drawn correctly. Modules C and D should be within a selection construct depending on the condition C1. Explain the error in the diagram and give a corrected version. [5]


Error : When a module connected upwards to another module is a selection, [1] all modules connected up to the same module must be selections [1]

Correct diagram

Correct second level by making use of X module [2][Award 1 mark if modules C and D are from B module] Correct third level [regardless whether from X or B module] [1]

b) The following fragment of JSP is also not drawn correctly. It is intended that function 1 should be carried out before the selection condition is evaluated. Explain the error in the diagram and give a corrected version. [5]

Error: There should not be any function number [in module A] [1] if the module contains some other sub-modules [1]

Correct diagram:

Correct second level by making use of X module with function number 1 [1]
Correct second level by making use of Y module [1]
Correct third level [from Y module] [1]

 

[10]
5. The Personnel Department of XYZ Hospital has adopted a scheme of promotions for its assistant nurses (AN) and staff nurses (SN). It is based on the following rules:

R1 - If an AN has > 5 years working experience, they should be promoted to senior AN
R2- If an AN has >5 years working experience and has completed an SN course, they should be promoted to SN
R3- If an AN has completed an SN course, has >5 years working experience and has good management skill, they should be promoted to senior SN
R4- If an AN has completed an SN course and has good management skill, they should be promoted to SN

Copy the decision table below to your answer booklet and complete it, based on the information given. [Note: Make sure you use the correct notation] [4]

  R1 R2 R3 R4
>5 years working experience        
Completed SN course        
Management skill        
         
Senior SN        
SN        

Senior AN

       

 

  R1 R2 R3 R4
>5 years working experience Y Y Y N
Completed SN course N Y Y Y
Management skill N N Y Y
         
Senior SN - - X -
SN - X - X
Senior AN X - - -

 

Correct entry of entire column of R1 [1]
Correct entry of entire column of R2 [1]
Correct entry of entire column of R3 [1]
Correct entry of entire column of R4 [1]
[No mark awarded if wrong notations are used] G

[4]
6.

List four factors that greatly affect the ease of program maintenance. [4]

Degree of program structure [1]
Modularity [1]
Complexity [1]
Level of documentation [1]

 

[4]
7.

a) State the main difference between High Level Languages and Fourth Generation Languages. [2]

High Level Language: A procedure-oriented language [1]
Fourth Generation Language: A non-procedure-oriented language [1]

b) State four different applications of Fourth Generation Languages. [4]

Database query language [1]
Report generator [1]
Application generator [1]
Decision support system [1]
[Accept reasonable alternative answers. Max 4 marks]

 

[6]
8.

State the level of correctness that can be achieved for a multiplication instruction, based on the following testing schemes:

a) Multiply 3 * 4 and check that the result is 12. [1]

Possible correctness

b) Every possible pair of numbers is tested for both operands. [1]

Absolute correctness

c) Several values are tested, including the obvious problem values such as zero, largest positive and negative numbers and so on. [1]

Probable correctness

[3]