



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!




Autumn Examinations 2011/
Module Code: SOFT 6011
School: Science and Informatics
Programme Title(s):
Higher Certificate in Computing (Evening) – Year 2 Bachelor of Science in Computing – Year 2 Bachelor of Science (Honours) in Software Development – Year 2
Programmes Code(s):
External Examiner(s): Mr. Peter Given
Internal Examiner(s):
Ms Gemma McSweeney Mr Tadhg Leane
Instructions: Answer Question 1 (compulsory) and TWO other questions of yourchoice
Duration: 2 Hours
Sitting: Autumn 2011/
Requirements for this examination: None
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the correct examination. If in doubt please contact an Invigilator.
Q1 Part A
Write sections of a program
(1) to set up a dynamic array of strings to hold student names doing a certain course. 4 (2) to set up a dynamic array of student identity numbers for the corresponding student names delivered in (Q1 section A (1) ) 4
(3) to include a function called readInStudentName s to read a set of student names using the array set up in (Q1 section A (1) ) 5
(4) to include a function readInStudentIDNumbers to read in a set of student identity numbers referring to the array set up in (Q1 section A (2)). 4
(5) to include a function to printOutStudentNameAnd StudentIdNumber to write out all students details for those present in the arrays set up in Q1( section A (1) & (2)) 5
Part A 22 Marks
Q1 Part B
Part B 10 Marks
Q2 Part A
i) Identify the error in the following code and provide and alternative correct solution:
int main() { char str1[] = "Hello"; char str2 [5]; str2 = str1; cout << str2; return 0; 5 }
ii) What is the outcome of the following code
char name[50]=”John”; char surname[50]=”Smith”; strcat (name, surname); strcat (surname, name); cout << name << endl; cout << surname << endl; 5
Part A 10 Marks
Q2 Part B
Write a program which detects whether a string is a palindrome or not. A palindrome is a word which is unchanged when the order of the letters is reversed. For example:
navan is a palindrome because the reverse is also navan
kayak is a palindrome because the reverse is also kayak
The program should prompt for a read a string input by the user. The program should then detect if this string is a palindrome or not.
Part B 20 Marks
Question 2 Total 30 Marks
Q3 Part A
i) What does the reference operator (&) in C++ do?
ii) When using a pointer to reference a C++ data structure (struct) what operator do you use to access the members of the struct?
iii) Assume the variable declarations:
int Foo = 0;
int *ptr = &Foo;
Identify all of the following statements which will change the value of Foo to 1 -note there may be more than one correct choice:
ptr++; 3) (*Foo)++;
Foo++; 4) (*ptr)++;
iv) If a variable is a pointer to an integer, then which of the following operators is used to access the integer value pointed to by the memory address stored in the pointer?
‘.’ 3) ‘*’
‘&’ 4) ‘->’
v) Briefly explain one benefit that can be gained from using pointers.
Part A 10 Marks ( 2 marks each)
Q3 Part B
What is the outcome of executing the following code:
int main () { char ac[] = {'c', 'h','a','r','\0'}; char * str = ac; cout << *str; char c = str[3]; cout << c; str[1]= ‘l’; ac[3]=’p’; cout << ac; return 0;
}
Part B 5 marks
Question 4 Total 30 Marks