A variable should hold the names of all past U.S. presidents. Which data type should the variable be?

Study for the WGU C173 Scripting and Programming Test. Dive into coding challenges and multiple-choice questions with expert explanations. Prepare thoroughly and excel!

The most suitable data type for storing the names of all past U.S. presidents is a string array. A string array allows for the storage of multiple string values, which in this case would represent the individual names of each president. This structure enables easy access, modification, and iteration over the list of names, making it ideal for any operations where you might want to retrieve, display, or manipulate the names of the presidents collectively.

Using just a single string to hold all names would complicate retrieval and processing since you would have to parse the names from a long concatenated string. Conversely, other data types like float or boolean arrays are not appropriate for this context, as floats are used for numerical values and booleans represent true/false values, neither of which can store textual data like names. Thus, choosing a string array offers the most intuitive and practical way to manage a collection of names in programming.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy