Based on your instructions, I assume the array containing the valid names for 10 cities in Michigan is named michigan_cities, and the user input for the city name is stored in a string variable named city_name.
Here's the completed program:#include <iostream>
#include <string>
int main() {
std::string michigan_cities[10] = {"Ann Arbor", "Detroit", "Flint", "Grand Rapids", "Kalamazoo", "Lansing", "Muskegon", "Saginaw", "Traverse City", "Warren"};
std::string city_name;
bool found = false; // flag variable to indicate if a match is found
std::cout << "Enter a city name: ";
std::getline(std::cin, city_name);
for (int i = 0; i < 10; i++) {
if (city_name == michigan_cities[i]) {
found = true;
break;
}
}
if (found) {
std::cout << city_name << " is a city in Michigan." << std::endl;
} else {
std::cout << city_name << " is not a city in Michigan." << std::endl;
}
return 0;
}
In the loop, we compare each element of the michigan_cities array with the user input city_name using the equality operator ==. If a match is found, we set the found flag to true and break out of the loop.
After the loop, we use the flag variable to determine whether the city name was found in the array. If it was found, we print a message saying so. If it was not found, we print a message saying it's not a city in Michigan.
When the program is executed with the given input, the output should be:
Enter a city name: Chicago
Chicago is not a city in Michigan.
Enter a city name: Brooklyn
Brooklyn is not a city in Michigan.
Enter a city name: Watervliet
Watervliet is a city in Michigan.
Enter a city name: Acme
Acme is not a city in Michigan.
Read more about programs here:
https://brainly.com/question/26134656
#SPJ1