CIT736 : COMPUTER PROGRAMMING (2014)

NATIONAL OPEN UNIVERSITY OF NIGERIA

14/16 AHMADU BELLO WAY, VICTORIA ISLAND, LAGOS

SCHOOL OF SCIENCE AND TECHNOLOGY

MARCH/APRIL 2014 EXAMINATION

COURSE CODE: CIT736

COURSE TITLE: COMPUTER PROGRAMMING

TIME ALLOWED: 2HOURS

INSTRUCTION: ATTEMPT ANY FOUR (4) QUESTIONS

Question 1

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:

i. It should accept values of n and c from the user as input

ii. 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

iv. 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

a. With the aid of a diagram, briefly explain the term “translator” (4 marks).

b. Explain briefly, the following types of program errors, stating examples in each case (7.5 marks):

i. Conversion error

ii. Round-off error

iii. Syntax error

iv. Runtime error

v. Logical error

c. List and explain briefly 4 properties of a good program. (6 marks)

Question 3

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)

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

Question 4

a. Draw the flowchart for a program that reads 3 integers and prints out their sum, product and average (7 marks)

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

c. Briefly explain the logic behind desk checking (2 marks)

Question 5

a. Complete the following table containing Pascal keywords/functions with the output/effect of each of statement (5 marks):

KeywordDescription/Effect
Clrscr
Gotoxy(int,int)
ReadKey
Delay(1000)
Halt(1)

b. Find errors, if any, in the following unformatted Pascal I/O statements:

i. Read (a; b; c); (2 marks)

ii. Write (“The sum is”, sum); (2 marks)

c. Suppose that we have data items; a = 10 and b = 44

i. Determine the output if the program segment is executed:

Read (a, b);

c = a ^ 2;

d = 2 * b;

Write (a, c, d);

(3 marks)

ii. 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 6

F=C*(9/5)+32 where F is Fahrenheit and C is Celsius

a. Write a Pascal/FORTRAN program to read and convert a Fahrenheit temperature supplied by a user to Celsius. (5.5 marks)

b. Draw the flowchart for the program in a. (3.5 marks)

c. Write a Pascal/FORTRAN program to read and convert a Celsius temperature supplied by a user to Fahrenheit. (5 marks)

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

For the 2015 – till date past questions for this course CLICK HERE

Contact me for your TMA, GST302 Business plan writeup, Project Writeup and also get your Exam Summary for this course.

Leave a Reply

MEET OVER 2000 NOUN STUDENTS HERE. 

Join us for latest NOUN UPDATES and Free TMA answers posted by students on our Telegram. 

OUR ONLINE TUTORIAL CLASS IS NOW ON!!! JOIN US NOW. 
JOIN NOW!
close-link
%d bloggers like this: