PPC125C Exam 2017
PPC125C Exam 2017
MAIN EXAM
STATIONERY:
1.
INSTRUCTIONS:
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 1
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
1.1. The loop control variable is initialized after entering the loop. (1)
1.2. In some cases, a loop control variable does not have to be initialized. (1)
1.4. You can either increment or decrement the loop control variable. (1)
1.5. When one loop appears inside another it is called an indented loop. (1)
1.6. Forgetting to initialize and alter the loop control variable is a common mistake that programmers
sometimes make. (1)
1.7. Every high-level computer programming language contains a while statement. (1)
1.8. Both the while loop and the for loop are examples of pretest loops. (1)
1.9. The safest action is to assign the value 1 to accumulators before using them. (1)
1.10. It is the programmer’s responsibility to initialize all variables that must start with a specific value. (1)
1.11. Many newer programming languages such as C++, Java, and C# use subscript 1 to access the first
element of the array. (1)
1.12. You use subscripts 1 through 10 to access the elements in a ten element array. (1)
1.13. Many newer programming languages such as C++, Java, and C# use the bracket notation for arrays. (1)
1.14. Declaring a named constant makes code easier to modify and understand. (1)
1.15. A parallel array is an array that stores another array in each element. (1)
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 2
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
1.16. Parallel arrays must contain the same data type. (1)
1.17. You can improve the efficiency of a program by leaving a loop as soon as a match is found in the array. (1)
1.18. Arrays cannot be used if you need to search for a range of values. (1)
1.19. When you have a five element array and use subscript 8, your subscript is said to be out of bounds. (1)
1.20. The for loop is a good tool when working with arrays because you frequently need to process every
element of an array from beginning to end. (1)
Multiple Choice
Identify the choice that best completes the statement or answers the question.WRITE DOWN THE LETTER ONLY
1.21. Once your logic enters the body of a structured loop, ____. (1)
a. the entire loop must execute
b. the loop can be terminated with a break statement
c. the loop will execute indefinitely
d. a decision statement will be evaluated
1.23. The ____ loop provides three actions in one compact statement. (1)
a. for c. do until
b. while d. repeat
1.24. Business reports that list only totals, with no individual item details, are called ____. (1)
a. detail reports c. transaction reports
b. summary reports d. control-break reports
1.25. ____ a data item means you override incorrect data by setting the variable to a specific value. (1)
a. Flexing c. Forcing
b. Tracing d. Blanking
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 3
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
1.26. All array elements have the same group ____. (1)
a. subscript c. memory location
b. name d. value
1.27. A ____ search starts looking in the middle of a sorted list, and then determines whether it should
continue higher or lower. (1)
a. linear c. quadratic
b. binary d. single lookup
1.28. The number of bytes in an array is always a multiple of the number of ____ in an array. (1)
a. subscripts c. iterators
b. elements d. indexes
1.29. In every programming language, when you access data stored in an array, it is important to use
a ____ containing a value that accesses memory occupied by the array. (1)
a. superscript c. key
b. subscript d. condition
1.30. When a subscript is not within the range of acceptable subscripts, it is said to be ____. (1)
a. a superscript c. out of bounds
b. flagged d. indexed
[30]
Question 2 (Theory)
[20]
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 4
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
[15]
4.1. Make use of the below C# code and provide the output that will be printed to the console screen. (10)
The program will print the following a few times with the answer of the inner and outer variables. Work through
the inner and outer for loop to provide the correct output.
The innerloop total is now:
The outerloop total is now:
The C# code to follow on the next page...
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 5
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//6 October 2017
//PPC125C Exam Question 4
//DeskChecking
//Provide the output when the below program will be executed
namespace PPC125C_Exam_Q4
{
class Program
{
static void Main()
{
int inner = 0, outer = 0;
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 6
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP
Writing the Program Tips: (Rewrite all below code in your book) -USE THE CORRECT SYNTAX!!!
namespace PPC125_Exam_Month
{
class Program
{
//Months of Year in String Array
static string[] Months = new string[] {null, "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
//Variable to get a number from the user to print Month. Number between 1 and 12 will be accepted.
static int MonthNumber;
………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 7