
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410 تمرين 7
Parallel Arrays
In this exercise, you use what you have learned about parallel arrays. Study the following code, and then answer Questions. Note that this code may contain errors.
string cities[] = "Chicago", "Rome", "Paris", "London";int populations[] = 2695598, 2760665, 2190777, 7805417;const int MAX_CITIES = 4;int foundIt;int i, x;string inCity;cout ? "Enter city name: ";cin ? inCity;for(i = 0; i = MAX_CITIES; ++i){if(inCity == cities[i]){foundIt = i;}}cout ? "Population for " ? cities[foundIt] ?" is " ? populations[foundIt] ? endl;
How would you describe the purpose of the statement foundIt = i;?
In this exercise, you use what you have learned about parallel arrays. Study the following code, and then answer Questions. Note that this code may contain errors.
string cities[] = "Chicago", "Rome", "Paris", "London";int populations[] = 2695598, 2760665, 2190777, 7805417;const int MAX_CITIES = 4;int foundIt;int i, x;string inCity;cout ? "Enter city name: ";cin ? inCity;for(i = 0; i = MAX_CITIES; ++i){if(inCity == cities[i]){foundIt = i;}}cout ? "Population for " ? cities[foundIt] ?" is " ? populations[foundIt] ? endl;
How would you describe the purpose of the statement foundIt = i;?
التوضيح
Parallel array:
Refer code provided in ...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
لماذا لم يعجبك هذا التمرين؟
أخرى 8 أحرف كحد أدنى و 255 حرفاً كحد أقصى
حرف 255