Download BASIC Programming Exam for Electronic Engineering Students at Cork Institute of Technology 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 Computing (Time: 3 Hours) Answer any four questions Maximum available marks is 100. 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 …. 2 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 ….