Small Basic Exercise: European Capitals

Here's a special exercise to try out! See if you can do it, and head to the forum if you have any questions!


Write a program that provides a review of selected European countries and their capitals. Create an array that associates a country’s name with its capital like this:

capital["Netherlands"] = "Amsterdam"

capital["Greece"]        = "Athens"

capital["Serbia"]         = "Belgrade"

capital["Germany"]     = "Berlin"


Include this data:

Belgium (Brussels); France (Paris); Germany (Berlin); Greece (Athens);
Ireland (Dublin); Italy (Rome); Poland (Warsaw); Portugal (Lisbon); Spain
(Madrid); United Kingdom (London)


Have your program prompt the user to enter the name of a country and then show her its capital like in the following sample run:

Enter the name of a European country: France

The capital of France is Paris


Enter the name of a European country: Germany

The capital of Germany is Berlin


Enter the name of a European country: Japan

Sorry, I don't know this


Next, update your program so that your user can enter the capital and get the country instead!


Do you have any questions? Ask us! We're full of answers and other fine things!

Head to the Small Basic forum to get the most answers to your questions:   

And go to to download Small Basic and learn all about it!


Small and Basically yours,

   - Ninja Ed & Majed Marji


Comments (1)
  1. Computers Today (part 1 of 6)…/computers-today.aspx


    CS SPOTLIGHT: Girls in computer programming… why it matters!!!…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

Comments are closed.

Skip to main content