adspace


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

Answer Posted / Bipin Bihari Chauhan

Here's some guidance to help you get started:

1. First, you need to decide how you will store the countries and capitals in your program. One way is to use an array of structs, where each struct represents a country with its capital. For example:

```c
typedef struct {
char country[50];
char capital[50];
} Country;
```

2. You can store multiple countries in an array of Country structs. Initialize this array with the countries and capitals you need.

3. In your main function, use a loop to read user input for country names. Use a function similar to the one I provided for the previous question to find the corresponding capital.

4. Print out the capital for each entered country.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category