Page 1 of 4
Extended Curriculum Programme (ECP)
MAIN TEST ASSIGNMENT
DATE: 28 October 2021 TIME: 09:00 TO 17:00
SUBJECT: Programming Principles 1A CODE: PPC125C
INSTRUCTIONAL PROGRAMMES: Diploma in Information Technology ECP,
Diploma in Computer Networking ECP.
INSTRUCTIONAL PROGRAMMES CODE: EX_ITC, EX_CMN
STATIONERY:
1. Answer Sheet Template (Supplied and please download)
2. Computer / Laptop
3. MS WORD, Adobe PDF
INSTRUCTIONS TO CANDIDATES:
1. Answer all questions in the MS Word Answer Sheet Template supplied.
2. Save the document as you student number
3. When writing C# code, Note the syntax must be correct and in this question paper
you may NOT use Visual Studio in this paper.
4 Make valid assumptions where necessary.
5. Make sure to submit the document correctly to Ethuto.
6. If possible, please convert the document to a PDF and upload, it assists us a lot.
7. LAB BHP222 & BHP224 will be available on 28 October 2021 - 12:25 TO 13:50 to
have a computer available if you need to complete and submit on Campus. Limited space!
ASSESSOR: Mr. AD van der Walt & Ms. M Tlale-Mkhize
MODERATOR: Mr. P Kruger
Duration of Paper: 1 ½ Hours (submit before 17:00! – open 8hours!!) Total marks: 35
Assessor’s Signature Moderator’s Signature
Page 2 of 4
QUESTION 1 Explain Theoretical Concepts [15]
1.1) In C# we mainly have 3 loops that we can use. Name each and provide the
basic C# declaration for each of them.
a) Loop 1 (3)
While Loop
while (boolean condition)
{
}
b) Loop 2 (3)
Do While Loop
do
{
}
while (test-expression);
c) Loop 3 (3)
FOR Loop
for (init; condition; increment)
{
}
1.2) Explain what an array is and how it occupies the Computer Memory. Also
provide the basic C# declaration of an Array. (6)
An array stores a fixed-size sequential collection of elements of the same type . An array
is used to store a collection of data, but it is often more useful to think of an array as a
collection of variables of the same type stored at contiguous memory locations.
datatype[] arrayname = new datatype[sizeofarray];
Assessor’s Signature Moderator’s Signature
Page 3 of 4
QUESTION 2 Write the C# code [20]
Given the following partial data of employees working at a certain company:
Each employee gets a different salary and all of them have unique names. In this program
the above data will be initialised in the three parallel arrays. The following C# code needs
to be written down:
2.1) The Global declaration for the three parallel arrays and initialising the arrays
with the values indicate above. (3 X 3 = 9)
static int[] numbers = new int[] { 111, 222, 333, 444, 555 };
static string[] names = new string[] {"Mabanza","Mofokeng","Akaba","Chabane","Hlabahlaba"};
static double[] salaries = new double[] {844111.55, 533222.66, 555444.33, 222333.44,711222.11};
2.2) a FOR Loop that will calculate the total for all the salaries. (just the code for
the FOR loop needs to be written down) (6)
for (int counter1 = 0; counter1 < 5; counter1++)
{
totalSalary = totalSalary + salaries[counter1];
}
2.3) Calculate the average for all the salaries and use a Console.WriteLine to
print the Total Salaries and Average Salary. (5)
averageSalary = totalSalary / 5;
Console.WriteLine("Total Salaries: {0}", totalSalary);
Console.WriteLine("Average Salary: {0}", averageSalary);
Assessor’s Signature Moderator’s Signature
Page 4 of 4
END OF PAPER
TOTAL MARKS = 35
Assessor’s Signature Moderator’s Signature