Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2 . answer in c language ou are given a task to implement a hierarchical data structure rep - resenting cities, regions, countries, and
Problem answer in c language ou are given a task to implement a hierarchical data structure representing cities, regions, countries, and continents. Your implementation should allow youto create instances of these entities, link them appropriately, and print specific hierarchicalinformation.The structures and relationships are as follows:EachCitybelongs to aRegion.EachRegioncontains multipleCitiesand belongs to aCountry.EachCountrycontains multipleRegionsand belongs to one or moreContinents.EachContinentcontains one or moreCountries.Here are the specific requirements: Define structures forCity,Region,Country, andContinent.Cityshould have the variables below:char nameCity nameint populationPopulation of the cityRegionshould have the variables below:char nameRegion nameint populationTotal population of the cities in the regionint numcitiesNumber of cities that the region hasCountryshould have the variables below:char nameCountry nameint populationTotal population of the cities in the countryint numregionsNumber of regions that the country hasint numcontinentsNumber of continents that the country hasContinentshould have the variables below:char nameContinent nameint populationTotal population of the cities in the continentint numcountriesNumber of countries that the continent has Create instances ofCity,Region,Country, andContinentand establish their relationships.Continentshould point toCountry
Countryshould point toContinentandRegion.Regionshould point toCountryandCity.Cityshould point toRegion Populate the data:Include two continents, named Europe and AsiaAsia contains one country, TurkeyEurope contains two countries, Turkey and FranceFrance has multiple regions, IledeFrance and NouvelleAquitaineTurkey has multiple regions, Marmara and EgeParis 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.Izmir population: and Manisa population: are in Ege region,Turkey.Istanbul 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 hierarchicalinformation:p r i n t f Continent : s
Europename ;p r i n t f Population : d
Europepopulation ;p r i n t f Number of Countries : d
Europenumcountries ;p r i n t f
;p r i n t f Country : s
Europecountry name ;p r i n t f Population : d
Europecountry population ;p r i n t f Number of Regions : d
Europecountry numregions ;p r i n t f Number of Continents : d
Europecountry numcontinents ;p r i n t f
;p r i n t f Country : s
Europecountry name ;p r i n t f Population : d
Europecountry population ;p r i n t f Number of Regions : d
Europecountry numregions ;p r i n t f Number of Continents : d
Europecountry numcontinents ;p r i n t f
;p r i n t f Country : s
Asiacountryname ;p r i n t f Population : d
Asiacountrypopulation ;p r i n t f Number of Regions : d
Asiacountrynumregions ;p r i n t f Number of Continents : d
Asiacountrynumcontinents ;p r i n t f
;p r i n t f Region : s
Europecountry region name ;p r i n t f This region i s in s
IleDeFrancecountryname ;p r i n t f s and s are in t h i s region
Europecountry region city name Europecountry region city name ;p r i n t f Population : d
Europecountry region population ;p r i n t f Number of C i t i e s : d
Europecountry region numcities ;p r i n t f
;p r i n t f City : s
Asiacountryregion cityname ;p r i n t f This city i s in s region s
Asiacountryregion name Asiacountryname ;p r i n t f Population : d
Asiacountryregion citypopulation ;struct Citymycity malloc s i z e o f struct City ; mycity Asiacountryregion city ;p r i n t f Istanbul i s the city that bridges s and s
mycityregioncountrycontinent name mycityregioncountrycontinent name ;p r i n t f
;p r i n t f Region : s
Asiacountryregion name ;
p r i n t f s and s ar
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started