A program stores 15 strings in the 1D array DataArray.
1(a)ArraysEasy1 mark
Write program code to declare the global 1D array DataArray with space for 15 string elements.
Answer
0 words
1(b)ArraysMedium4 marks
The procedure CreateArray() takes 15 strings as input from the user. Each input is converted to lower case and stored in DataArray in the order input.
Write program code for CreateArray().
Answer
0 words
1(c)ArraysEasy2 marks
The procedure OutputArray() outputs the data in each element in DataArray on one line with a space between each element.
Write program code for OutputArray().
Answer
0 words
1(d)(i)Subroutines Scope Modular ProgrammingEasy1 mark
Write program code for the main program to call CreateArray() and then OutputArray().
Answer
0 words
1(d)(ii)ArraysEasy1 mark
Run your program from 1(d)(i). Enter the following data for the inputs, in the order given: 1, One, 2, TWO, three, ??, house, 99987, popping, green, eleven, 12, Twenty, THIRTY, 16.
Describe exactly what your program outputs, in the order it is produced.
Answer
0 words
1(e)Searching AlgorithmsMedium5 marks
The procedure FindWords() takes a string as input from the user and converts it to lower case. The procedure counts and outputs the number of times the input is stored in DataArray.
Write program code for FindWords(). Do not use an in-built function to count the number of times the input is stored in DataArray.
Answer
0 words
1(f)(i)Sorting AlgorithmsMedium5 marks
The procedure SortLength() uses a bubble sort to order the elements in DataArray into ascending order by the length of each string.
The bubble sort needs to be efficient and stop iterating as soon as it identifies that DataArray is in the correct order.
Write program code for SortLength(). Do not use an in-built function to sort the array or check if the array is in the correct order.
Answer
0 words
1(f)(ii)Subroutines Scope Modular ProgrammingEasy1 mark
Write program code to extend the main program by calling FindWords() then SortLength() then OutputArray().
Answer
0 words
1(f)(iii)Sorting AlgorithmsEasy1 mark
Run your extended program. Enter the following data to be stored in the array, in the order given: one, One, 1, three, three, One, house, 99987, popping, green, eleven, One, Twenty, THIRTY, One.
Enter "one" as the string to find in the array.
Describe exactly what your program outputs, in the order it is produced.