Question: In C++ Write a program that will make changes in the list of strings by modifying its last element. Your program should have two functions:
In C++

Write a program that will make changes in the list of strings by modifying its last element. Your program should have two functions: 1. To change the last element in the list in place. That means, without taking the last element from the list and inserting a new element with the new value. 2. To compare, you need also to write a second function that will change the last element in the list by removing it first, and inserting a new element with the new value. The main creates the list, creates the string variables, add few elements to the list (couple is enough) and calls the functions to modify the list. After each call to the functions, the main should print out the value of the last element in the list, so the changes are visible. Again, you print the last element not from within the functions, but from the main. Note 1: You will need to use references to implement the in-place requirement. Note 2: However difficult that assignment may look like, all information you need on how to work with the list is given to you in the lecture and both your functions implementation are just very few short statements (hint: If you find yourself writing 5 or more lines of codes for each function, you probably do it wrong). Comment your program: Programmer: Your name Purpose: State the purpose of the program. Class: CS222 Describe all variables Describe important sections of code. Grading Comments Indentation Meaningful variables names Program runs Correct input and output Total 2 points 2 points 2 points 7 points 7 points 20 points Not correct handling of references: -4 points Program crashes (Or I may think it'll crash) -4 points No run file or incorrect run file -4 points Main does not print the values of the last element -2 points. others as deemed appropriate
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
