



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Semester 1 Repeat Examinations 2011
Module Code: COMP
School: Electrical and Electronic Engineering
Programme Title: Bachelor of Engineering in Electronic Engineering
Programme Code: ELES_L8_Y
External Examiner(s): Dr. A. Donnellan, Mr. I. Kennedy Internal Examiner(s): Donal OāDonovan
Instructions: All questions must be answered
Practical Section: Console and Windows: Using a PC with the Visual Basic.NET programming environment, complete the exercises indicated. [Examination percentage: 70 %]
Instructions: (a) Each program should be stored in a separate project folder. (Select the āCreate new folderā option when creating the project.) (b) Save all projects on the desktop. (c) The project name should be formatted as follows: o āname question numberā, e.g., John_Smith_Q (d) The final projects should be copied to a machine designated by the invigilator at the end of the examination. o It is the studentās responsibility to verify the correct transfer of the project files to the invigilatorās machine. (e) The VB.NET code for each program should also be printed off and inserted into your answer book (see Theory Section). Your name and question number should be clearly marked on each print-out page.
Theory Section: A hand-written response is required for these questions. [Examination percentage: 30 %] Instructions: ļ· All questions should be answered in answer book provided.
NOTE: This is a closed-book examination. Although, you may use the help supplied by the Visual Basic programming environment, if you wish.
1. Write a console-based Visual Basic.NET programming project to perform the following:
i. Generate a random number between 100 and 1000 called FILE_SIZE. [3 %]
ii. Write a sub-procedure to: (a) Generate FILE_SIZE random integer numbers between 150 and
(b) Return the random numbers to the calling function, i.e. , main(), in an array of size FILE_SIZE and stored (in main()) in an integer array called dataArray. [3 %]
(c) The numbers should be written to a file, called āc:\myfolder\datafile.datā. Each random number should be stored on a separate line. [7 %]
iii. Write a function, called RollingAverage, to calculate the average of five integer values passed by value as an array to the function. The ārollingā average result should be returned as the result of the function call.
i.e. ,^0 1 2 3 5
array array array array array RollingAverage ļ« ļ« ļ« ļ« (^) ļ½ [5 %]
iv. Define a structure, called RollingStruct, consisting of: [4 %]
o A rolling-average array, called RollingArray, which stores five integer elements (used in the calculation the rolling average in (iv)).
o A single-precision floating-point number used to store the corresponding rolling average value, called rollingAvg.
v. In main(), define an array of RollingStruct structures (see iv.), called structArray, of size FILE_SIZE ā 4 and redim the RollingArray field of each structure to a size of 5 elements. [4 %]
vi. In main(), write code to populate the rolling-average array RollingArray in each RollingStruct structure of the array of structures structArray in (v) with integer data values from dataArray in (ii (b)).
iii. Display the currently-selected ListData item in the Display Label. [3 %]
iv. If the checkbox āDouble speedā is ticked, the timer speed should double. [4 %]
v. The scroll bar tab position should increase by one, resetting when the maximum position is reached. [4 %]
(c) Add a menu bar to your application with one menu called āFileā and insert an option to āQuitā the program into the File submenu. [2 %]
[26 %]
(Continued Over)
In an examination booklet, answer the following:
(b) Explain the difference passing arguments to a function using the ābyRefā and ābyValā options. [4 %]
(c) Demonstrate, using diagrams, how recursion may be used to generate Fibonacci series Fn ļ½ Fn (^) ļ 1 ļ« Fn ļ 2 with seed values F 0 (^) ļ½ 0 and F 1 (^) ļ½ 1. Write code to implement the Fibonacci series. [10 %]
(d) Using diagrams to illustrate your answer, give a detailed explanation of the operation of the āSelection Sortā sorting algorithm. [10 %]
[30 %]