Chapter 8: Problem 26
include
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
Chapter 8: Problem 26
include
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for freeWrite C++ statements that do the following: a. Declare an array alpha of 10 rows and 20 columns of type int. b. Initialize the array alpha to 0. c. Store 1 in the first row and 2 in the remaining rows. d. Store 5 in the first column, and make sure that the value in each subsequent column is twice the value in the previous column. e. Print the array alpha one row per line. f. Print the array alpha one column per line.
Suppose that you have the following function definition: void sum(int x, int y, int& z) { z = x + y; } Consider the following declarations: int list1[10], list2[10], list3[10]; int a, b, c; Which of the following function calls is valid? a. sum(a, b, c); b. sum(list1[0], list2[0], a); c. sum(list1, list2, c); d. for (int i = 1; i <= 10; i++) sum(list1[i], list2[i], list3[i]);
Suppose that scores is an array of 10 components of type double, and: scores = {2.5, 3.9, 4.8, 6.2, 6.2, 7.4, 7.9, 8.5, 8.5, 9.9} The following is supposed to ensure that the elements of scores are in nondecreasing order. However, there are errors in the code. Find and correct the errors. for (int i = 1; i <= 10; i++) if (scores[i] >= scores[i + 1]) cout << i << " and " << (i + 1) << " elements of scores are out of order." << endl;
include
Consider the following declarations: const int CAR_TYPES = 5; const int COLOR_TYPES = 6; double sales[CAR_TYPES][COLOR_TYPES]; a. How many components does the array sales have? b. What is the number of rows in the array sales? c. What is the number of columns in the array sales? d. To sum the sales by CAR_TYPES, what kind of processing is required? e. To sum the sales by COLOR_TYPES, what kind of processing is required?
What do you think about this solution?
We value your feedback to improve our textbook solutions.