Loops - Computing - Exam, Exams of Computer Science

Main points of this past exam are: Loops, Functions, Variables, Debugging, Programming Language, Price Difference, Average of the Numbers

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lalchand
lalchand 🇮🇳

4.4

(67)

117 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Higher Certificate in Engineering in Electronic Engineering – Stage 1
(NFQ Level 6)
Autumn 2006
Computing
(Time: 3 Hours)
Answer any four questions
Maximum available marks is 100.
Examiners: Mr. P Cogan
Mr. J. Berry
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) Debugging.
(iv) Loops. [8 marks]
(b) Explain each line of the following program, draw the program’s output and
describe what happens if the numbers 25 and 0 are entered. [10 marks]
DIM FirstNum, SecondNum Temp AS INTEGER
CLS
PRINT
INPUT "Enter a number", FirstNum
INPUT "Enter another number", SecondNum
REM Test numbers
IF FirstNum > SecondNum THEN
Temp = FirstNum
FirstNum = SecondNum
SecondNum = temp
END IF
PRINT
PRINT FirstNum; " ";
PRINT SecondNum
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
pf4

Partial preview of the text

Download Loops - Computing - Exam and more Exams Computer Science in PDF only on Docsity!

Cork Institute of Technology

Higher Certificate in Engineering in Electronic Engineering – Stage 1

(NFQ Level 6)

Autumn 2006

Computing

(Time: 3 Hours)

Answer any four questions Maximum available marks is 100.

Examiners: Mr. P Cogan Mr. J. Berry 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) Debugging. (iv) Loops. [8 marks]

(b) Explain each line of the following program, draw the program’s output and describe what happens if the numbers 25 and 0 are entered. [10 marks] DIM FirstNum, SecondNum Temp AS INTEGER CLS PRINT INPUT "Enter a number", FirstNum INPUT "Enter another number", SecondNum REM Test numbers IF FirstNum > SecondNum THEN Temp = FirstNum FirstNum = SecondNum SecondNum = temp END IF PRINT PRINT FirstNum; " "; PRINT SecondNum 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. [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 simple BASIC program that reads in values for the temperature, pressure and RPM of an engine. The program should display the words TEMPERATURE ALARM if the temperature is less than 0 or bigger than 100 degrees. The program should display the words PRESSURE ALARM if the pressure is more than 10 and the engine is running. The program should display STALL ALARM if the RPM is between 1 and 1000. Hint: one of the values read in lets you determine if the engine is running. [12 marks] (25 Marks in total)

Q3. (a) Explain using examples why there are two different types of loop in BASIC. [4 marks]

(b) Give the syntax of the following two BASIC statements: (i) FOR … NEXT (ii) DO … LOOP [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 ….

Q5. (a) Using examples discuss the differences between sub-programs and functions. [5 marks]

(b) Write a program that offers the user the following menu of options. Each operation should be written in a separate subprogram that is called from the main module. The program should continue to offer options to the user until the user chooses to quit.

******Menu******

  1. Calculate emitter current given collector and base current
  2. Calculate collector and emitter currents given base current and hfe.
  3. Display table of the collector currents for a range of base currents
  4. Quit

Option 1 should calculate the emitter current using the formula IE =I (^) C+I (^) B, where I (^) E is the emitter current, I (^) C is the collector current and I (^) B is the base current. The program should not proceed until positive values are entered for I (^) C and I (^) B.

Option 2 should calculate the collector and emitter currents using the formula I (^) C=hfe.I (^) B and the formula for IE given above. Under no circumstances should hfe be zero, the value entered must be checked to prevent this.

Option 3 should display a table of the collector current from a starting base current to a finishing base current using the formula used in option 2. The user should enter hfe and the starting and finishing base currents. The user should also be asked to enter the increment size that IB will change by in the table. For example if hfe =100 and the increment size is 0.5, the program might generate a table that looks like the following; continued overleaf …. IB IC 0.5 50 1.0 100 1.5 150

Option 4 should cause the program to end. [20 marks] (25 Marks in total)

ooooOOOOoooo