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 B [60 Marks]

Click here to access other sections
Section A
Front Cover

Click to access
SUGGESTED SOLUTIONS
for Section B

Answer any TWO questions in this section

 

1. a) A program is to be developed to read in a collection of exam scores ranging in value from 0 to 100. Range validation is to be carried out on the exam scores entered. If a score is not within the permissible range, an error message is to be displayed and the user should be allowed to re-enter the score.

Your program should count the number of outstanding scores (90-100), the number of satisfactory scores (60-89), the number of unsatisfactory scores (1-59), and the number of zero scores.

At the end of the run, your program should display the number of students in each category (i.e. outstanding, satisfactory, unsatisfactory, and zero) and the average exam score.

An outline of a program flowchart is given on the next page, with some conditions and actions omitted. The program variables names to be used are:

score, outstd, sat, unsat, zero, count, sum and average

Your task is to 'fill in' the gaps:

     i) Draw the boxes and actions for initialisation, to replace dotted      box (i).      [2]

     ii) State the condition for selection box (ii). Note carefully which      way      round the 'yes' and 'no' branches are. [1]

     iii) State the action for box (iii). [1]

     iv) Draw the box for the final output, to replace dotted box (iv). [2]

     v) State the condition for selection box (v). [1]

     vi) State the condition for selection box (vi) [1]

     vii) State the condition for selection box (vii) [1]

     viii) State the condition for selection box (viii). [1]

     ix) State the action for box (ix). [1]

     x) Draw the boxes and actions, to replace dotted box (x). [2]


b) Consider the following diagram of the stages of the System Life Cycle. For each point (i) to (x), identify one document that you would expect to find at this point of the cycle. [10]

c)  i) Briefly explain what is meant by structured programming. [2]

     ii) State five advantages of using structured programming. [5]

 

[30]
2.

a) A sample screen design for the main menu of a program is as follows:

The main menu will be displayed again after selection of each choice if users do not select choice 4.

In choice 1, the user is prompted for a collection of records and the records will then be stored in a file.

In choice 2, all the records from the file will be retrieved and displayed on the screen.

In choice 3, the user is prompted to enter a target key field. All of the records which match the target will be displayed as the program will retrieve one record from the file at a time, and compare it with the target key field. If it matches, the record is displayed. If it does not match, the next record is retrieved and so on until the end of file.

In choice 4, the user is able to end the program.

Using a CASE_ENDCASE construct, express the program logic using Pseudocode.

(Note: Do not use IF_THEN_ELSE_ENDIF construct to process the menu choices) [13]


b) i) Explain briefly what a recursive module is. [2]

    ii) State three essential components of a recursive module. [3]

    iii) State one advantage and one disadvantage of using recursion as     compared to iteration. [2]

c) Name and briefly describe five types of data processing files. (Do not give examples) [10]

 

[30]
3. a) Consider the following program:

Step no.
1.            FOR i = 1 TO 2
               DO
2.                      k = 10
3.                      FOR j = 1 TO 3
                         DO
4.                               IF i mod j = 0 THEN
                                            DO
5.                                                 DISPLAY i
6.                                                 DISPLAY j
                                            ENDDO
                                  ELSE
7.                                         k = k - 2
                                  ENDIF
                          ENDDO
                ENDDO

Dry run the above code showing, at each step, the content of the variables i, j, k and the other expressions involving i, j and k. Take care to show the execution of each numbered statement. [13]

b) There are three kinds of loop-control statements often found in programming languages: for, while and repeat-until.

    i) When would you use the for loop construct? [1]

    ii) State the differences between a repeat-until loop and a while loop, in     terms of :

·       execution of the loop body [2]
·       the loop condition and execution of the loop body [2]

c) i) Give short descriptions of the following types of decision table :

·      Limited entry decision table [2]
·      Extended entry decision table [3]
·      Mixed entry decision table [2]

    ii) Write brief notes to explain the purpose of a decision table preprocessor.     [3]

d) State the two types of high level language translator. [2]

[30]