

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this past exam are: Stepwise Refinement Technique, Design, Simple Calculator Program, Operations Addition, Subtraction, Multiplication and Division, Implement the Program
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


(NFQ Level 8)
Answer Question 1 and THREE others All questions carry equal marks
Examiners: Mr. D. O’Donovan Prof. G. Hurley Dr. S. Foley
(b) Rewrite the following for loop with (i) a while loop and (ii) a do..while loop. int p, q; for (p = 0; p < 15; p++) { printf (“P is %d”, p); printf (“X Squared is %d”, X* X); } [7 %]
(c) i. Read in a sentence (terminated by full stop) and output the number of space characters it contains;
ii. Read in a list of numbers from the keyboard with a sentinel of -1 and output their sum and average; [10 %]
(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 %]
(b) Is it possible to shorten the Boolean expression given in the example? Explain your answer. [4 %]
(c) Write a function which accepts the two following parameters:
i) An integer array ii) The number of values within the integer array
(i) Display a horizontal line of asterisks ‘*’ for each value in the array. The number of asterisks per line should equal the corresponding integer array value e.g. value[0]=5 *****, value[1]=3 ***, etc. [7 %]
(ii) The function should determine the (1) sum and (2) average of the numbers in the array. The two values should be displayed on screen. The average value should be returned as the result of the function. [8 %]