Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 17, Problem 24RQE
Program Plan Intro
Standard Template Library (STL) list container:
The STL includes the collection of data types and algorithms which can be used by the programmer in their programs.
The STL “list” container is a template version of “doubly” linked list. The elements of the container can iterate either forward or backward. It can grow at either front or back of the list.
The header file named “#include<list>” is used to implement the list container in a
Syntax:
Syntax to insert values into “STL list” container is as follows:
variable_name.push_back(value);
- “variable_name” is the name of the list which is defined by user.
- “push_back(value)” is a method to add a new element containing a “value” at end of the container.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a function called find_big_words . The function should accept a list as a parameter. Parts of the program which you are not coding will call the function and past it lists of words. The function must analyze the words in the list and return all the words which are 6 or more characters long. The returned list should be in alphabetical order. NB: Only write the function. Do not call it.
For example:
Test
Result
random_words1 = find_big_words(["nation", "night", "news", "negotiation", "newspaper", "nature"]) print(random_words1)
['negotiation', 'newspaper']
random_words3 = find_big_words(["examination","test", "testing", "quiz", "exam", "assessment"]) print(random_words3)
['assessment', 'examination', 'testing']
What does the following error message
normally mean?
IndexError: list index out
of range
Select one:
а.
This error normally indicates that
you have tried to access an element
of a list that doesn't exist.
O b. This error normally means that you
have used the range() function
incorrectly.
С.
This error normally means that you
have used a list where you should
have used a tuple.
d. This error normally means that you
used too many lines of code in your
program.
OCaml Code: Attached are the instructions. Make sure to read the instructions carefully and write your own test cases to make sure the code works. Make sure to include a screenshot of the correct code with the test cases that is used along with the output of the code being passed.
Chapter 17 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 17.1 - Prob. 17.1CPCh. 17.1 - Prob. 17.2CPCh. 17.1 - Prob. 17.3CPCh. 17.1 - Prob. 17.4CPCh. 17.2 - Prob. 17.5CPCh. 17.2 - Prob. 17.6CPCh. 17.2 - Prob. 17.7CPCh. 17.2 - Prob. 17.8CPCh. 17.2 - Prob. 17.9CPCh. 17.2 - Prob. 17.10CP
Ch. 17 - Prob. 1RQECh. 17 - Prob. 2RQECh. 17 - Prob. 3RQECh. 17 - Prob. 4RQECh. 17 - Prob. 5RQECh. 17 - Prob. 6RQECh. 17 - Prob. 7RQECh. 17 - Prob. 8RQECh. 17 - Prob. 9RQECh. 17 - Prob. 10RQECh. 17 - Prob. 11RQECh. 17 - Prob. 13RQECh. 17 - Prob. 14RQECh. 17 - Prob. 15RQECh. 17 - Prob. 16RQECh. 17 - Prob. 17RQECh. 17 - Prob. 18RQECh. 17 - Prob. 19RQECh. 17 - Prob. 20RQECh. 17 - Prob. 21RQECh. 17 - Prob. 22RQECh. 17 - Prob. 23RQECh. 17 - Prob. 24RQECh. 17 - Prob. 25RQECh. 17 - T F The programmer must know in advance how many...Ch. 17 - T F It is not necessary for each node in a linked...Ch. 17 - Prob. 28RQECh. 17 - Prob. 29RQECh. 17 - Prob. 30RQECh. 17 - Prob. 31RQECh. 17 - Prob. 32RQECh. 17 - Prob. 33RQECh. 17 - Prob. 34RQECh. 17 - Prob. 35RQECh. 17 - Prob. 1PCCh. 17 - Prob. 2PCCh. 17 - Prob. 3PCCh. 17 - Prob. 4PCCh. 17 - Prob. 5PCCh. 17 - Prob. 6PCCh. 17 - Prob. 7PCCh. 17 - List Template Create a list class template based...Ch. 17 - Prob. 9PCCh. 17 - Prob. 10PCCh. 17 - Prob. 11PCCh. 17 - Prob. 12PCCh. 17 - Prob. 13PCCh. 17 - Prob. 14PCCh. 17 - Prob. 15PC
Knowledge Booster
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
- From the code supplied by the tutor, modify it so that: 1. Ask what kind of animal it is (for example, carnivore, herbivore, and omnivore) When prompting for the information, it is saved in a list for each of the three animal types (for example, lions in carnivores, bears in omnivores, giraffes in herbivores) and they are saved depending on the number that the user adds in each list. 2. At the end, a list of lists is printed that presents the data of each of the saved animals according to their type.arrow_forwardIn C++, first, make a set with 10 objects, then ask the user to enter a value for search in your list. if the value exists then print "the value you are looking for that is in the set", otherwise print "The value you are looking for that is not in the list".arrow_forwardCreate a flowchart for the following code. namesList=['Juan','Rae','Ivanna','Lilly','Robert']; #list to store names wagesHoursDict={7.50:35, 11.00:41, 18.25:26, 9.25:35, 11.10:45}; #dictionary to store wages and hours grossPay=0; #variable to store gross pay wagesList=list(wagesHoursDict.keys()); #convert all the keys of dictionary to listhoursList=list(wagesHoursDict.values()); #convert all the values of dictionary to list print("Name\tWages\tHours\tGross Pay"); #print header for i in range(0,5): if(hoursList[i]>40): #if hours more than 40 #calculate basic for 40 hours and 1.5 times basic for remaining hours grossPay=(wagesList[i]*40)+(1.5*wagesList[i]*(hoursList[i]-40)); else: grossPay=wagesList[i]*hoursList[i]; #calculate hours*wage print(namesList[i],"\t",wagesList[i],"\t",hoursList[i],"\t",grossPay); #printing all the valuesarrow_forward
- Create a list that stores the marks of the subject “R language” of 10 students. Take random marks for all 10 students. Explain the indexing on the list. Write R code to access the fifth and seventh marks from the list.arrow_forwardGiven: a variable current_members that refers to a list, and a variable member_id that has been assigned a value. Write some code that assigns True to the variable is_a_member if the value assigned to member_id can be found in the current_members list. Otherwise, assign False to is_a_member. In your code, use only the variables current_members, member_id, and is_a_member.arrow_forwardWrite a statement that will print the first letter of each element of the following list: list1 = [‘Galileo’,‘Oliver’,’Ostwald’,’Descartes’].arrow_forward
- Please see attachementarrow_forwardpaython programing question Write a program that creates a list of N elements (Hint: use append() function), swaps the first and the last element and prints the list on the screen. N should be a dynamic number entered by the user. Sample output: How many numbers would you like to enter?: 5 Enter a number: 34 Enter a number: 67 Enter a number: 23 Enter a number: 90 Enter a number: 12 The list is: [12, 67,23, 90, 34]arrow_forward1. Create the list fruits = ['Apple',"Banana', "Cherry','Date', Eggfruit', Fig', Grape'] 2. print the fruits in the list whose character length is less than or equal to 4. %3D 1 fruits = ['Apple','Banana', 'Cherry', 'Date', 'Eggfruit', 'Fig', 'Grape'] 2 for i in fruits: 4. Date Figarrow_forward
- Phyton: Program 6: Write a program that allows the user to add data from files or by hand. The user may add more data whenever they want. The print also allows the user to display the data and to print the statistics. The data is store in a list. It’s easier if you make the list global so that other functions can access it. You should have the following functions: · add_from_file() – prompts the user for a file and add the data from it. · add_by_hand() – prompts the user to enter data until user type a negative number. · print_stats() – print the stats (min, max, mean, sum). You may use the built-in functions. Handling errors such as whether the input file exist is extra credit. To print a 10-column table, you can use the code below: for i in range(len(data)): print(f"{data[i]:3}", end="") if (i+1)%10==0: print() print() Sample run: Choose an action 1) add data from a file 2) add data by hand 3) print stats 4)…arrow_forwardName: ID: A 6. Consider the following code segment. Assume that index1 is a number between 1 and LENGTH(theList), inclusive, and index2 is a number between 2 and LENGTH(theList) - 1, inclusive. theList [9, -1, 5, 2, 4, 8] x + theList[index1] + theList[index2] What is the largest possible value that the variable x can have after the code segment executes? а. 4 с. 14 b. 11 d. 17arrow_forwardIf you have downloaded the source code from this book’s companion Web site, you will find a file named USPopulation.txt in the Chapter 07 folder. The file contains the midyear population of the United States, in thousands, during the years 1950 through 1990. The first line in the file contains the population for 1950, the second line contains the population for 1951, and so forth.Write a program that reads the file’s contents into a list. The program should display the following data:• The average annual change in population during the time period• The year with the greatest increase in population during the time period• The year with the smallest increase in population during the time period(You can access the book’s companion Web site at www.pearsonglobaleditions.com/gaddis.)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education