BASIC Programming Exam for Cork Institute of Technology - Autumn 2007, Exams of Computer Science

Information about a basic programming exam held at cork institute of technology in autumn 2007. The exam covers various topics such as functions, variables, constants, loops, and basic programming. It includes four questions, each with multiple parts, and each question is worth 25 marks. The document also includes examples of basic code and instructions for writing programs to perform specific tasks.

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lallit
lallit 🇮🇳

4

(27)

150 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Bachelor of Engineering in Electronic Automation and Robotics - Stage 1
Bachelor of Engineering in Applied Electronics Design - Stage 1
Bachelor of Engineering in Communications Systems - Stage 1
(NFQ Level 7)
Autumn 2007
Computer Science
(Time: 3 Hours)
Answer any four questions.
Maximum available marks is 100.
All questions carry equal marks.
Examiners: Mr. P Cogan
Mr. D. Denieffe
Dr. R. Dubhghaill
Q1. (a) Write a note discussing how each of the following relates to the BASIC
programming language;
(i) Functions
(ii) Variables.
(iii) Constants.
(iv) Loops. [8 marks]
(b) Explain each line of the following program, draw the program’s output and
describe what happens if the number 4 is entered. [10 marks]
DIM N, T, L AS INTEGER
CLS
PRINT
INPUT "Enter a positive integer", N
T = 1
FOR L = 1 TO N
T = T * L
NEXT L
PRINT “Original value = “;N;
PRINT " and the result is "; T
PRINT
END
(c) Write a simple BASIC program that reads in the destination names and costs
of two holidays. The program should then report on which holiday is the
cheapest and the price difference between the holidays. [7 marks]
(25 Marks in total)
continued overleaf ….
pf3

Partial preview of the text

Download BASIC Programming Exam for Cork Institute of Technology - Autumn 2007 and more Exams Computer Science in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Engineering in Electronic Automation and Robotics - Stage 1

Bachelor of Engineering in Applied Electronics Design - Stage 1

Bachelor of Engineering in Communications Systems - Stage 1

(NFQ Level 7)

Autumn 2007

Computer Science

(Time: 3 Hours)

Answer any four questions. Maximum available marks is 100.

All questions carry equal marks.

Examiners: Mr. P Cogan Mr. D. Denieffe Dr. R. Dubhghaill

Q1. (a) Write a note discussing how each of the following relates to the BASIC programming language; (i) Functions (ii) Variables. (iii) Constants. (iv) Loops. [8 marks]

(b) Explain each line of the following program, draw the program’s output and describe what happens if the number 4 is entered. [10 marks] DIM N, T, L AS INTEGER CLS PRINT INPUT "Enter a positive integer", N T = 1 FOR L = 1 TO N T = T * L NEXT L PRINT “Original value = “;N; PRINT " and the result is "; T PRINT END (c) Write a simple BASIC program that reads in the destination names and costs of two holidays. The program should then report on which holiday is the cheapest and the price difference between the holidays. [7 marks] (25 Marks in total) continued overleaf ….

Q2. (a) Cells B5 to B8 on a spreadsheet contain a list of numbers in ascending order.

Write down and explain the formulae that you would place in a cell to; (i) add up the numbers (ii) get the average of the numbers (iii) find the number closest to but not exceeding 12.51 (^) [7 marks]

(b) Write a BASIC program that reads in an exam mark and grades it as follows; 0 to 30 = F 30 to 40 = E 40 to 50 = Pass 50 to 60 = Merit 2 60 to 70 = Merit 1 70 or above = Distinction [6 marks]

(c) Write a BASIC program that simulates a fortune-teller. It should read in a question from the user and then generate a random number between 1 and 5. Based on this random number it should display one of the following messages. (^) [12 marks]

Random Number Message 1 Yes, definitely 2 Ask again, later 3 No way! 4 It is certain. 5 Yes (25 Marks in total)

Q3. (a) Give the syntax and an example of the count controlled loop structure. Draw a

flowchart to illustrate your answer. [4 marks]

(b) Give the syntax of the following two BASIC statements: (i) FOR … NEXT (ii) SELECT … CASE [4 marks]

(c) Briefly distinguish between post-test loops and pre-test loops. [2 marks]

(d) Write a program, using NESTED FOR LOOPS , which produces the following output:

**


**** [5 marks] (e) Write a program that will sum a list of positive integers entered by the user, terminating when the user enters a zero. Any negative numbers entered should be ignored. [10 marks] (25 Marks in total) continued overleaf ….