Question: Problem 2 . ( 5 0 pts ) ou are given a task to implement a hierarchical data structure representing cities, regions, countries, and continents.
Problem pts ou are given a task to implement a hierarchical data structure representing cities, regions, countries, and continents. Your implementation should allow you to create instances of these entities, link them appropriately, and print specific hierarchical information.
The structures and relationships are as follows:
Each City belongs to a Region.
Each Region contains multiple Cities and belongs to a Country.
Each Country contains multiple Regions and belongs to one or more Continents.
Each Continent contains one or more Countries.
Here are the specific requirements:
Define structures for City, Region, Country, and Continent.
City should have the variables below:
char name City name
int population Population of the city
Region should have the variables below:
char name Region name
int population Total population of the cities in the region
int numcities Number of cities that the region has
Country should have the variables below:
char name Country name
int population Total population of the cities in the country
int numregions Number of regions that the country has
int numcontinents Number of continents that the country has
Continent should have the variables below:
char name Continent name
int population Total population of the cities in the continent int numcountries Number of countries that the continent has
Create instances of City, Region, Country, and Continent and establish their relationships.
Continent should point to Country.
Country should point to Continent and Region.
Region should point to Country and City.
City should point to Region.
Populate the data:
Include two continents, named "Europe" and "Asia".
Asia contains one country, "Turkey".
Europe contains two countries, "Turkey" and "France".
France has multiple regions, "IledeFrance" and "NouvelleAquitaine".
Turkey has multiple regions, "Marmara" and "Ege".
Paris and Yvelines two cities in France are in IledeFrance, and the corresponding populations are and respectively.
Bordeaux a city in France with population is in NouvelleAquitaine.
zmir population: and Manisa population: are in Ege region. Turkey.
stanbul population: is in Marmara region, Turkey.
Ensure proper memory allocation for dynamic data.
Name the variables so that the program will be able to print the following hierarchical information:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
