Suppose you have a file named "Countries.txt" containing a list of countries: USA, Brazil, Germany, India, Japan, Australia, Canada, Mexico, China, France, South Korea,Italy, Spain, Argentina, Russia, Sweden, Turkey, Nigeria, Egypt, South Africa

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20SA
icon
Related questions
Question
100%
Don't try to copy other's work or don't use any AI platform to generate answer. If I see these things I'll give you multiple downvotes for sure and will report.
Suppose you have a file named "Countries.txt"
containing a list of countries:
USA, Brazil, Germany, India, Japan, Australia,
Canada, Mexico, China, France,
South Korea, Italy, Spain, Argentina, Russia, Sweden,
Turkey, Nigeria, Egypt, South Africa
Write a C++ program that reads the countries from
the file and performs the following tasks:
Output all the countries in your STL list of strings.
Output all countries that have a length greater than
5 characters.
Output all countries that do not start with the letter
'S'.
Calculate the sum of ASCII values of all characters in
each country and store the result in a histogram of
length 5, where each element represents a range of
values (e.g., 0-100, 101-200, etc.).
Store all the countries in an STL set<string>
container.
Output all unique countries from the set.
Output the total number of entries in your set.
Transcribed Image Text:Suppose you have a file named "Countries.txt" containing a list of countries: USA, Brazil, Germany, India, Japan, Australia, Canada, Mexico, China, France, South Korea, Italy, Spain, Argentina, Russia, Sweden, Turkey, Nigeria, Egypt, South Africa Write a C++ program that reads the countries from the file and performs the following tasks: Output all the countries in your STL list of strings. Output all countries that have a length greater than 5 characters. Output all countries that do not start with the letter 'S'. Calculate the sum of ASCII values of all characters in each country and store the result in a histogram of length 5, where each element represents a range of values (e.g., 0-100, 101-200, etc.). Store all the countries in an STL set<string> container. Output all unique countries from the set. Output the total number of entries in your set.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning