Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programing: Finish the PrintCountryNames() function to print all country names in the list. #include #include #include const int MAX_COUNTRY_NAME_LENGTH = 50; typedef struct CountryTvWatch_struct

C Programing: Finish the PrintCountryNames() function to print all country names in the list.

#include #include #include

const int MAX_COUNTRY_NAME_LENGTH = 50;

typedef struct CountryTvWatch_struct { char countryName[50]; int tvMinutes; } CountryTvWatch;

void PrintCountryNames(CountryTvWatch ctryList[], int numCountries) { printf("FIXME: Finish PrintCountryNames()"); return; }

int main(void) { // Source: www.statista.com, 2010 const int NUM_COUNTRIES = 4;

CountryTvWatch countryList[NUM_COUNTRIES]; char countryToFind[MAX_COUNTRY_NAME_LENGTH]; bool countryFound = false; int i = 0; strcpy(countryList[0].countryName, "Brazil"); countryList[0].tvMinutes = 222; strcpy(countryList[1].countryName, "India"); countryList[1].tvMinutes = 119; strcpy(countryList[2].countryName, "U.K."); countryList[2].tvMinutes = 242; strcpy(countryList[3].countryName, "U.S.A."); countryList[3].tvMinutes = 283; printf("Enter country name: "); scanf("%s", countryToFind); countryFound = false; for (i = 0; i < NUM_COUNTRIES; ++i) { // Find country's index if (strcmp(countryList[i].countryName, countryToFind) == 0) { countryFound = true; printf("People in %s watch ", countryToFind); printf("%d minutes of TV daily. ", countryList[i].tvMinutes); } } if (!countryFound) { printf("Country not found, try again. "); printf("Valid countries: "); PrintCountryNames(countryList, NUM_COUNTRIES); } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago

Question

Discuss the goals of financial management.

Answered: 1 week ago