##### ExamsSCHOOL OF SCIENCE AND TECHNOLOGY

# National Open University Exam Past Question – CIT736 JUNE/JULY EXAMINATION

**N****A****TIONAL OPEN UNIVERSITY OF NIGERIA CIT736 Computer Programming**

**1****4/16 AHMADU BELLO WAY, VICTORIA ISLAND, LAGOS SCHOOL OF SCIENCE AND TECHNOLOGY JUNE/JULY EXAMINATION**

**COURSE CODE: CIT736**

**COURSE TITLE: Computer Programming (2 units)**

**TIME ALLOWED: 2 hours**

**I****N****STRUCTION: Attempt any four (4) questions**

1.

- a. With the aid of a diagram, briefly explain the term “translator” (4 marks).
- Explain briefly, the following types of program errors, stating examples in each case (7.5 marks):
- Conversion error ii. Round-off error iii. Syntax error
- Runtime error
- Logical error
- c. List and explain briefly 4 properties of a good prog (6 marks)

2.

- a. Write a FORTRAN 90/95 program to compute the sum, product and average of any n integers where n>=0. In particular ensure that the program handles the case n=0 without yielding any errors (10 marks)
- Caching promotes efficiency when 2 conditions are met. State those 2 conditions (3 marks). c. State and explain 3 methods/ways to step through code during debugging (4.5 marks)

3

- a. Draw the flowchart for a program that reads 3 integers and prints out their sum, product and average (7 marks)
- Write a Pascal program that calculates and displays the squares of all numbers between 1 and

1000 as well as the sum and average of these squares. (8.5 marks)

- Briefly explain the logic behind desk checking (2 marks)

4.

- a. Given the probability function P=(1-n!)/((n-c)!*n^c), where
**n**is the number of days in a year,**c**is the size of the population, write a FORTRAN program to calculate and display the value of P given any value of n and c. The program should work as follows: - It should accept values of n and c from the user as input
- It MUST contain a function called
**fact**which accepts a single argument and returns its factorial iii.**fact**must be used in the program to calculate all factorial values - The final program should return the value of the probability P. (13 marks)

- What is the difference between a FORTRAN function and a FORTRAN subroutine? (2.5 marks)
- What is the advantage of using functions and subroutines in FORTRAN programs? (2 marks)

5.

- a. Complete the following table containing Pascal keywords/functions with the output/effect of

each of statement (5 marks):

Keyword |
Description/Effect |

Clrscr | |

Gotoxy(int,int) | |

ReadKey | |

Delay(1000) | |

Halt(1) |

- Find errors, if any, in the following unformatted Pascal I/O statements:
- Read (a; b; c); (2 marks)
- Write (“The sum is”, sum); (2 marks)
- c. Suppose that we have data items; a = 10 and b = 44
- Determine the output if the program segment is executed: Read (a, b);

c = a ^ 2; d = 2 * b; Write (a, c, d); (3 marks)

- If the write statement is changed to: Writeln (a, c);

Write (d); (2 marks)

- Write a pascal program to read the values 2.34, 1.25, 3.25 and prints each value, one per line, with formatted output of one decimal place and a field width of 5. (5.5 marks)

- F=C*(9/5)+32 where F is Fahrenheit and C is Celsius
- a. Write a Pascal program to read and convert a Fahrenheit temperature supplied by a user to

Celsius. (5.5 marks)

- Draw the flowchart for the program in a. (3.5 marks)
- Write a Pascal program to read and convert a Celsius temperature supplied by a user to

Fahrenheit. (5 marks)

- Draw the flowchart for the program in c. (3.5 marks)