0% found this document useful (0 votes)
19 views

PPC125C Exam 2017

This is a coding exam from 2017 for programing principles

Uploaded by

kkgwebdesign
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

PPC125C Exam 2017

This is a coding exam from 2017 for programing principles

Uploaded by

kkgwebdesign
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP

MAIN EXAM

DATE: 01 November 2017 SESSION: 14:00

SUBJECT: Programming Principles CODE: PPC125C

STATIONERY:
1.

EXAMINER: Mr. AD van der Walt / Ms. M Tlale

MODERATOR: Mr. F Zulu

INSTRUCTIONAL PROGRAMME: CODE:


Diploma in Information Technology ECP EX_ITC
Diploma in Computer Networking ECP EC_CMN

INSTRUCTIONS:

Duration of paper: 120 Minutes Maximum marks: 80

THIS PAPER CONSISTS OF 7 PAGES, INCLUDING THE COVER PAGE.

………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 1
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP

Question 1 (Multiple Choice)


True/False
Indicate whether the statement is true or false. WRITE DOWN TRUE OR FALSE ONLY

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.3. An indefinite loop is a loop that never stops. (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.22. A(n) ____ loop executes a predetermined number of times. (1)


a. Terminal c. indefinite
b. Definite d. infinite

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)

2.1. What are the advantages of Looping? (3)


2.2. Name the three steps that should occur in every properly functioning loop. (3)
2.3. What is the difference between PreTest Loop and a Post Test Loop (4)
2.4. Name the three ways Constants can be used in arrays. (3)
2.5. Explain the different parts of an Array. (3)
2.6. Name the first four (4) techniques for searching an array. (4)

[20]

………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 4
FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY ECP

Question 3 (Convert Pseudocode to flowchart)


3.1. Convert the following Pseudocode module (findItem) to a flowchart. (15)

[15]

Question 4 (Desk checking)

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;

for(int count = 1; count <= 3; count++)


{
for(int count2 = 1; count2 <= 2; count2++)
{
inner = inner + count2;
Console.WriteLine("The innerloop total is now: {0}",inner);
}
outer = outer + count;
Console.WriteLine("The outerloop total is now: {0}", outer);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit program...");
Console.ReadKey();
}
}
}
[10]

Question 5 (Write the C# code)


5.1. Write a C# program that will accept a number from the user and then the program will print the Month
Name. The Program will accept only a number between 1 and 12 and run in a loop until a number in this
range has been entered. The output of the program must look as follows: (5)

Screenshot & Tips on next page …

………………………………… ……………………………….
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;

static void Main()


{
HouseKeeping(); //get input from user and check that number entered is between 1 & 12 in a loop
PrintMonth(); // print the number the user entered from the array
}

static void HouseKeeping()


{
//Write your code...
}

static void PrintMonth()


{
//Write your code...
}
}
}
[5]
TOTAL 80 - END OF PAPER

………………………………… ……………………………….
EXAMINER MODERATOR
PAGE 7

You might also like