×
Log in to StudySoup
Get Full Access to C++ For Everyone - 2 Edition - Chapter 7 - Problem P7.10
Join StudySoup for FREE
Get Full Access to C++ For Everyone - 2 Edition - Chapter 7 - Problem P7.10

Already have an account? Login here
×
Reset your password

Write a function int* read_data(int& size) that reads data from cin until the userter

C++ for Everyone | 2nd Edition | ISBN: 9780470927137 | Authors: Cay S. Horstmann ISBN: 9780470927137 356

Solution for problem P7.10 Chapter 7

C++ for Everyone | 2nd Edition

  • Textbook Solutions
  • 2901 Step-by-step solutions solved by professors and subject experts
  • Get 24/7 help from StudySoup virtual teaching assistants
C++ for Everyone | 2nd Edition | ISBN: 9780470927137 | Authors: Cay S. Horstmann

C++ for Everyone | 2nd Edition

4 5 1 421 Reviews
20
3
Problem P7.10

Write a function int* read_data(int& size) that reads data from cin until the userter minates input by entering Q. The function should set the size reference parameterto the number of numeric inputs. Return a pointer to an array on the heap. Thatarray should have exactly size elements. Of course, you wont know at the outsethow many elements the user will enter. Start with an array of 10 elements, anddouble the size whenever the array fills up. At the end, allocate an array of thecorrect size and copy all inputs into it. Be sure to delete any intermediate arrays.

Step-by-Step Solution:

Step 1 of 2

The program requires to write a function that takes the values from the user input and stores in the array until the user enters Q. The size of the array starts at 10. And if user enters more items than this, the size of the arrays is doubled. The total number of elements entered by the user are also calculated. At the end, the array is initialized with the correct number of elements and the elements entered by user are stored in it.

Step 2 of 2

Chapter 7, Problem P7.10 is Solved
Textbook: C++ for Everyone
Edition: 2
Author: Cay S. Horstmann
ISBN: 9780470927137

Other solutions

Discover and learn what students are asking







Statistics: Informed Decisions Using Data : Applications of the Normal Distribution
?Explain why P(X ? 220) should be reported as > 70.9999 if X is a normal random variable with mean 100 and standard deviation 15.


Statistics: Informed Decisions Using Data : Inference on the Least-Squares Regression Model and Multiple Regression
?Crickets make a chirping noise by sliding their wings rapidly over each other. Perhaps you have noticed that the number of chirps seems to increase wi

Statistics: Informed Decisions Using Data : Inference about the Difference between Two Medians: Dependent Samples
?Secchi Disk A Secchi disk is an 8-inch-diameter weighted disk painted black and white and attached to a rope. The disk is lowered into water, and the



People also purchased

Related chapters

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

Write a function int* read_data(int& size) that reads data from cin until the userter