Exam Questions for Bachelor of Engineering in Electronic Engineering - Computer Science, Exams of Computer Science

Exam questions for the computer science module of the bachelor of engineering (honours) in electronic engineering program at cork institute of technology. The questions cover topics such as algorithm design, for and while loops, functional programming, and bus fare discount calculation. Students are required to write algorithms, implement them in c, and answer theoretical questions.

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lallit
lallit 🇮🇳

4

(27)

150 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Page 1 of 5
Bachelor of Engineering (Honours) in Electronic Engineering – Stage 1
(NFQ – Level 8)
Summer 2007
Computer Science
(Time: 3 Hours)
Answer Question 1 and THREE others Examiners: Prof. G. Hurley
Dr. S. Foley
Mr. D. O’Donovan
1. A soccer ground requires a computerised booking system to allocate seats in a terrace for a single
match. The terrace consists of 15 rows of 50 seats each.
(a) Using a stepwise refinement approach, design an algorithm to implement the booking
system. The user should, through a menu system, be able to do the following:
(i) Reserve seats;
(ii) Determine if a seat is occupied;
(iii) Display a list of all seats booked. [10 %]
(b) Implement the algorithm designed in part (a) as a C program. Use functions with
parameters where appropriate. [12 %]
(c) Briefly describe how the data arrays and functions used in the system would be modified to
allow a fan book tickets for a specific game in the season, e.g., the fan should be able to
book three seats for the fourth game in the season. [3 %]
pf3
pf4
pf5

Partial preview of the text

Download Exam Questions for Bachelor of Engineering in Electronic Engineering - Computer Science and more Exams Computer Science in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Engineering (Honours) in Electronic Engineering – Stage 1

(NFQ – Level 8)

Summer 2007

Computer Science

(Time: 3 Hours)

Answer Question 1 and THREE others Examiners:^ Prof. G. Hurley Dr. S. Foley Mr. D. O’Donovan

  1. A soccer ground requires a computerised booking system to allocate seats in a terrace for a single match. The terrace consists of 15 rows of 50 seats each. (a) Using a stepwise refinement approach, design an algorithm to implement the booking system. The user should, through a menu system, be able to do the following: (i) Reserve seats; (ii) Determine if a seat is occupied; (iii) Display a list of all seats booked. [10 %] (b) Implement the algorithm designed in part (a) as a C program. Use functions with parameters where appropriate. [12 %] (c) Briefly describe how the data arrays and functions used in the system would be modified to allow a fan book tickets for a specific game in the season, e.g., the fan should be able to book three seats for the fourth game in the season. [3 %]
  1. (a) Describe, with the aid of examples, the syntax and operation of the FOR and WHILE loops.

[6 %] (b) Write a program to prompt the user to enter a value, t (^) final , in seconds between 0 and 15

seconds. Using the formula, ( ) 5 1 where 3 secs

t v t e^ τ τ

, write the resulting values

between 0 and t (^) final at 10 m s intervals to (i) on-screen and (ii) a file called “results.dat”, at increments of 0.01secs, in the following fashion:

Time t : Value v t ( ):

etc.

Hint: The C command double exp( double x ); generates the e x function [12 %]

(c) Show the modifications necessary to the program in (b) such that the user may enter the terminating voltage at which the program is required to stop. [7 %]

  1. (a) Describe the purpose and benefits of using a functional approach to writing programs. [5 %]

(b) Describe two possible uses of the return type of a function. [2 %]

(c) Write a function which calculates how many characters are uppercase within the string supplied as a parameter to the function called ‘UpperCaseCount’. The number of uppercase characters should be returned as the result of the function. [10 %]

(d) Write a function to reverse the contents of a string supplied as an argument. [8 %]

  1. (a) Write conditional expressions that check for the following (assume x and y are integers and

ch is a character) i. x is a number between 4 and 16 ii. x is any number other than 6 or 10. iii. ch is an uppercase character vi. x is a positive even number divisible by 12 v. x is an odd number between 3 and 9. [10 %]

(b) i. The code segment in Figure 5-1 does not operate as expected – explain why. [3 %] ii. How would you correct this situation? [3 %] #include <stdio.h> void main() { float count; count = 0.0; while (count != 3.4) { printf(“\n%f",count); count+=0.2; } } Figure 5-

(c) A student grade is derived from its mark as follows:

Mark Student Grade 100 - 80 A 79 - 60 B 59 - 40 C 39 - 0 F

Write a C function which will return the appropriate student grade representing the mark supplied as an argument. [9 %]

  1. (a) i. What are the three essential elements of a for loop? Illustrate your answer with examples. [6 %] ii. Describe the circumstances under which the use of a for loop would be deemed appropriate. [2 %]

(b) i. Rewrite the for loop in Figure 6-1 with (i) a while loop and (ii) a do-while loop.

for (x = 1;x<=20;x++) { printf (“x is %d\n”, x); printf (“x squared is %d\n”, x*x); } Figure 6-1 [6 %]

ii. Explain the difference between pre-test and post-test while loops. [3 %]

(c) Rewrite the nested if statements in code segment 6-2 with a single switch statement. if ((number == 5) || (number == 7)) printf (“Clause One\n”); else if ((number > 0) && (number < 4)) printf (“Clause Two\n”); else if (number==0) printf (“Clause Three\n”); else if ((number==6) ||(number > 7)&&(number <= 10)) { printf (“Clause ”); printf (“Four\n”); } else if (x==4) printf (“Clause Five\n”); Figure 6-2 [8 %]