Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pseudo-code pieces are shown below. Which one describes the steps to reading 4 b

ID: 3562652 • Letter: P

Question

Pseudo-code pieces are shown below. Which one describes the steps to reading 4 button presses from the hex keypad? (Hint, changes from the code presented in option (a) are in bold)

a)

1. define an array of 4 chars to hold the IDs of the buttons pressed
2. wait for a button press (using the blocking keypad read function)
3. store the ID of the button pressed in to the array of 4.
4. wait for the key to be released
5. repeat steps 2-4 three more times

b.

1. define an array of 4 chars to hold the IDs of the buttons pressed
2. wait for a button press (using the blocking keypad read function)
3. store the ID of the button pressed in to the array of 4.
4. wait for the key to be released
5. repeat steps 2-4 four more times

c.

1. define an array of 4 chars to hold the IDs of the buttons pressed
2. wait for a button press (using the non-blocking keypad read function)
3. store the ID of the button pressed in to the array of 4.
4. wait for the key to be released
5. repeat steps 2-4 three more times

d.

1. define an array of 4 chars to hold the IDs of the buttons pressed
2. wait for a button press (using the blocking keypad read function)
3. store the ID of the button pressed in to the array of 4.
4. wait for the key to be released
5. repeat steps 1-4 three more times

Explanation / Answer

Option (a) is right becasue

1. You do not need to define array every single time after taking input one char has 4 bits and is enough to store a hex input, so 4 char array would be enough to take 4 inputs. So, only steps 2-4 should be repeated.

2. Blocking keypad read function should be used.

3. The steps 2-4 should be repeated 3 more times for the next 3 inputs.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote