Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Problem 24

When an array is passed as an actual parameter to a function, what is actually being passed?

Problem 25

In \(\mathrm{C}++,\) as an actual parameter, can an array be passed by value?

Problem 26

Given the declaration: char string15 [16]; mark the following statements as valid or invalid. If a statement is invalid, explain why. a. strcpy(string15, "Hello there"); b. strlen(string15); c. string15 = "Jacksonville"; d. cin >> string15; e. cout << string15; f. if (string15 >= "Nice day") cout << string15; g. string15[6] = 't';

Problem 27

Given the declaration: char str1[15]; char str2[15] = "Good day"; mark the following statements as valid or invalid. If a statement is invalid, explain why. a. str1 = str2; b. if (str1 == str2) cout << " Both strings are of the same length." << endl; c. if (strlen(str1) >= strlen(str2)) str1 = str2; d. if (strcmp(str1, str2) < 0) cout << "str1 is less that str2." << endl;

Problem 31

Define a two-dimensional array named temp of three rows and four columns of type int such that the first row is initialized to 6,8,12,\(9 ;\) the second row is initialized to 17,5,10,\(6 ;\) and the third row is initialized to 14,13,16,20.

Problem 33

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?

Problem 34

Write 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.

Problem 35

Consider the following declaration: int beta[3][3]; What is stored in beta after each of the following statements executes? a. for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) beta[i][j] = 0; b. for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) beta[i][j] = i + j; c. for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) beta[i][j] = i * j; d. for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) beta[i][j] = 2 * (i + j) % 4;

Problem 36

Suppose that you have the following declarations: int times[30][7]; int speed[15][7]; int trees[100][7]; int students[50][7]; a. Write the definition of the function print that can be used to output the contents of these arrays. b. Write the C++ statements that call the function print to output the contents of the arrays times, speed, trees, and students.

Access millions of textbook solutions in one place

  • Access over 3 million high quality textbook solutions
  • Access our popular flashcard, quiz, mock-exam and notes features
  • Access our smart AI features to upgrade your learning
Get Vaia Premium now
Access millions of textbook solutions in one place

Recommended explanations on Computer Science Textbooks