Computer Science – Arrays | e-Consult
Arrays (1 questions)
Login to see all questions.
Click on a question to view the answer
Here's pseudocode demonstrating the use of an array to store names:
- Declare an array called
friendNamesto hold 5 strings. - Assign the names of the friends to the array elements.
friendNames[0] = "Alice"friendNames[1] = "Bob"friendNames[2] = "Charlie"friendNames[3] = "David"friendNames[4] = "Eve"- To access the name of the second friend, use the index 1. The pseudocode would be:
friendName = friendNames[1]. This would assign the value "Bob" to the variablefriendName.