C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 16, Problem 16.10E
Program Plan Intro
- Include necessary header files.
- Create a
vector “myint” to store numbers from file. - Make fileinifstream object pointing to file “input_file.txt”.
- Make two istream_iteratorsfileit initialized with filein object and end_iiterator
- Copy into vector, numbers from file using back_inserter.
- Display vector using dereference
- Exit and return
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C Language)
A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names.
Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. Assume also the maximum number of characters of all file names is 100.
-Using a python program Write a python program that reads from an imbedded JSON
file and retrieves elements and attributes (Solution: myjson.py, myjson2.py)
Answer in C++ code please!
(Duplicate Elimination with vector) Use a vector to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the vector only if it isn't a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Begin with an empty vector and use its push_back function to add each unique value to the vector.
Chapter 16 Solutions
C++ How to Program (10th Edition)
Ch. 16 - Exercises 16.4 State whether each of the following...Ch. 16 - Fill in the blanks in each of the following...Ch. 16 - Prob. 16.6ECh. 16 - Prob. 16.7ECh. 16 - (Duplicate Elimination) Read 20 integers into an...Ch. 16 - (Duplicate Elimination) Modify Exercise 16.8 to...Ch. 16 - Prob. 16.10ECh. 16 - (Merging Ordered Lists) Write a program that uses...Ch. 16 - Prob. 16.12ECh. 16 - Prob. 16.13E
Knowledge Booster
Similar questions
- Debug the following phython code. """This function reads in data from the file specified by filename. This data is read line by line and unpacked into a single variable called data. argumentsfilename - the name of the file to be read returnsdata - a list of data, each element is a list that corresponds to the set of entries separated by commas in the original file. To access the first entry use data[0]. If x = data[0], then x[0], through x[3] will correspond to entries in the file that are read in. """ def read_file(filename):fin = open(filename,'r')line = fin.readline()data = []while line:data.append(parse_line(line))line = fin.readline()return dataarrow_forwardCODE: PYTHONarrow_forwardcan someone help me with this problem in C and explain how to do it step by steparrow_forward
- 1. In a loop, fill an array for up to 50 even numbers and a set for up to 50 odd numbers. Use the merge() algorithm to merge these containers into a vector. Display the vector contents to show that all went well. (In C++ language) 2. Write a program that copies a source file of integers to a destination file, using stream iterators. The user should supply both source and destination filenames to the program. You can use a while loop approach and a list container with integer data type. Within the loop, read each integer value from the input iterator and add the value to the list container by using push_back() function, then increment the input iterator.Finally, use an output iterator to write the list to the destination file. (In C++ language)arrow_forwardwrite in python Note:- Do not provide handwritten solution. Maintain accuracy and quality in your answer. Take care of plagiarism. Answer completely. You will get up vote for sure.arrow_forwardCan you give the answer to these two questionsarrow_forward
- Fix my C++ code please! Question and code is below as well as error picture. (Duplicate Elimination with vector) Use a vector to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the vector only if it isn't a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Begin with an empty vector and use its push_back function to add each unique value to the vector. My code; #include <iostream>#include <vector> using namespace std;int find(vector<int> &v, int num) { for(int i = 0; i < v.size(); ++i) { if(v[i] == num) { return i; } } return -1;}int main() { vector<int> v; int num; for(int i = 0; i < 20; ++i) { cout << "Enter an Integer : "; cin >> num; if(num >= 10 && num <= 100 && find(v, num) == -1) {…arrow_forwardFix my C++ code please! Question and code is below as well as error picture. (Duplicate Elimination with vector) Use a vector to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the vector only if it isn't a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Begin with an empty vector and use its push_back function to add each unique value to the vector. My code (I think it is missing commas); #include <iostream>#include <vector>using namespace std;int find(vector<int> &v, int num) { for(int i = 0; i < v.size(); ++i) { if(v[i] == num) { return i; } } return -1;}int main() { vector<int> v; int num; for(int i = 0; i < 20; ++i) { cout << "Enter an integer: "; cin >> num; if(num >= 10 && num <= 100 &&…arrow_forwardPlease,Explain your work. Thank you!arrow_forward
- use java languagearrow_forward4. Write a C++ code that: 1. Read the sequences in the provided fasta file (unzip the attached file) 2. Build a Kmer count table (use array) where k = 10%; 3. Build a histogram table of size 200 in which we store the frequency of counts collected in step 2. if frequency is 200 or more, increment the last element in the histogram array. 4. Report the results of histogram table to screen as the following: Kmer-Count Frequency 1 100 80 3 40 20 .... 200 300arrow_forwardAnswer the given question with a proper explanation and step-by-step solution.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