Answer:
Complete the program as follows:
for(int i = 0; i<10; i++){
if(inCity == citiesInMichigan[i]){
foundIt = true;
break; } }
if(foundIt){ cout<<"It is a city"; }
else{ cout<<"Not a city"; }
Explanation:
Required
Complete the pre-written code in C++ (as indicated by the file name)
The pre-written code; though missing in this question, can be found online.
The explanation of the added lines of code is as follows:
This iterates through the array
for(int i = 0; i<10; i++){
This checks if the city exists in the array
if(inCity == citiesInMichigan[i]){
If yes, foundIt is updated to true
foundIt = true;
And the loop is exited
break; } } -- The loop ends here
If foundIt is true, print it is a city
if(foundIt){ cout<<"It is a city"; }
Print not a city, if otherwise
else{ cout<<"Not a city"; }