##### ExamsSCHOOL OF SCIENCE AND TECHNOLOGY

# National Open University Exam Past Question – CIT736 October, 2013 Examination

**N****A****TI****O****N****A****L OPEN UNIVERSITY OF NIGERIA CIT736 Computer Programming**

14/16, Ahmadu Bello Way, Victoria Island

**S****C****HOOL OF SCIENCE AND TECHNOLOGY October, 2013 Examination**

**C****OURSE CODE: CIT736**

**C****OURSE TITLE: Computer Programming Instruction: Attempt any four (4) questions Time: 2 hrs**

**Question 1**

- 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) b. What is the difference between a FORTRAN function and a FORTRAN subroutine? (2.5 marks) c. What is the advantage of using functions and subroutines in FORTRAN programs? (2 marks)

**Question 2**

Write a Basic Program find the square and cube root a number (x). (17 marks)

**Question 3**

- 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) |

- b. Find errors, if any, in the following unformatted Pascal I/O statements:
- Read (a; b; c); (2 marks)
- ii. Write (“The sum is”, sum); (2 marks)

p.t.o

- 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)

- d. 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)

**Question 4**

Explain the following terms;

a) | Conversion Error | (4 marks) |

b) c) d) e) |
Syntax Error Round-off Error Run-time Error Logical Error |
(3 marks) (4 marks) (3 marks) (3 marks) |

**Question 5**

- 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)

- b. Caching promotes efficiency when 2 conditions are met. State those 2 conditions (3 marks).
- State and explain 3 methods/ways to step through code during debugging (4.5 marks)

**Question 6**

Write short notes on the following

- a) Machine Language (3 marks) b) Symbolic languages (3 marks) c) High Languages (3 marks) d) Subroutine (4 marks) e) Looping (4 marks)