expand icon
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

النسخة 8الرقم المعياري الدولي: 978-1285867410
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

النسخة 8الرقم المعياري الدولي: 978-1285867410
تمرين 5
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;
Is the for loop written correctly? If not, how can you fix it?
التوضيح
موثّق
like image
like image

Note:
Refer code provided in Exercise 6-...

close menu
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Chapter 1: An Introduction to C and the C++ Programming Environment
مجاني
arrow img
Chapter 2: Variables, Constants, Operators, and Writing Programs Using Sequential Statements
arrow img
Chapter 3: Writing Programs That Make Decisions
arrow img
Chapter 4: Writing Programs Using Loops
arrow img
Chapter 5: Using Arrays in C++ Programs
arrow img
Chapter 6: File Handling and Applications
arrow img
Chapter 7: Advanced Array Techniques
arrow img
Chapter 8: Advanced Modularization Techniques
arrow img
Chapter 9: Object Oriented C++
arrow img
cross icon