Photo AI

Button [4.1 - Codes] Write code to do the following: Remove all the special characters from each code in the array to create a new code - NSC Information Technology - Question 4 - 2023 - Paper 1

Question icon

Question 4

Button-[4.1---Codes]--Write-code-to-do-the-following:--Remove-all-the-special-characters-from-each-code-in-the-array-to-create-a-new-code-NSC Information Technology-Question 4-2023-Paper 1.png

Button [4.1 - Codes] Write code to do the following: Remove all the special characters from each code in the array to create a new code. Count how many special cha... show full transcript

Worked Solution & Example Answer:Button [4.1 - Codes] Write code to do the following: Remove all the special characters from each code in the array to create a new code - NSC Information Technology - Question 4 - 2023 - Paper 1

Step 1

Remove all the special characters

96%

114 rated

Answer

Start by initializing an empty string sLine to store the new code without special characters. Loop through the arrCodes array by index. For each code, loop through its characters, checking if each character is either a letter (a-z, A-Z) or a digit (0-9). If a character passes the test, concatenate it to sLine.

After processing the code, determine the length of the original code and subtract the length of sLine from it to find the number of special characters removed. Finally, display the new code and the count in the format <New code>(number of special characters deleted).

Step 2

Place extra IT periods

99%

104 rated

Answer

Initialize a counter for the week (Monday to Thursday). Loop through the days, checking if each cell in the arrTimeTable for the current day is blank. If it is, assign 'IT' to the first available period. Increment the counter each time an 'IT' is placed.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;