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 1

Mark the following statements as true or false. a. A double type is an example of a simple data type. b. A one-dimensional array is an example of a structured data type. c. Arrays can be passed as parameters to a function either by value or by reference. d. A function can return a value of type array. e. The size of an array is determined at compile time. f. The only aggregate operations allowable on int arrays are the increment and decrement operations. g. Given the declaration: int 1 ist [10]; the statement: 1 ist [5]=1 ist [3]+1 ist [2]; updates the content of the fifth component of the array list. h. If an array index goes out of bounds, the program always terminates in an error. i. In C++, some aggregate operations are allowed for strings. ¡. The declaration: char name[16] = "John K. Miller"; declares name to be an array of 15 characters because the string "John K. Miller" has only 14 characters. k. The declaration: char str = "Sunny Day"; declares str to be a string of an unspecified length. I. As parameters, two-dimensional arrays are passed either by value or by reference.

Problem 2

Consider the following declaration: double salary[10]; In this declaration, identify the following: a. The array name. b. The array size. c. The data type of each array component. d. The range of values for the index of the array.

Problem 3

Identify error(s), if any, in the following array declarations. a. int list[10] b. constint size =100; double list [SIZE]; c. int numList [09]; d. string names [20]; e. scores [50] double;

Problem 4

Determine whether the following array declarations are valid. If a declaration is invaid, explain why. a. int 1 ist 75; b. int size; double list [size]; c. int test [-10]; d. double sales [40.5];

Problem 5

What would be a valid range for the index of an array of size 50?

Problem 6

Write C++ statements to do the following: a. Declare an array alpha of 15 components of type int. b. Output the value of the tenth component of the array alpha. c. Set the value of the fifth component of the array alpha to 35. d. Set the value of the ninth component of the array alpha to the sum of the sixth and thirteenth components of the array alpha. e. Set the value of the fourth component of the array alpha to three times the value of the eighth component minus 57. f. Output alpha so that five components per line are printed.

Problem 7

What is the output of the following program segment? int temp [5] \[  For (inti=0;i<5;i++) temp [i]=2i3r for (inti=0;i<5;i++) cout << temp [i]<<m, \] cout << endl cout << endl;

Problem 8

Suppose list is an array of five components of type int. What is stored in list after the following C++ code executes? for (int i = 0; i < 5; i++) { list[i] = 2 * i + 5; if (i % 2 == 0) list[i] = list[i] - 3; }

Problem 9

Suppose list is an array of six components of type int. What is stored in 1 ist after the following C++ code executes? list[0] = 5; for (int i = 1; i < 6; i++) { list[i] = i * i + 5; if (i > 2) list[i] = 2 * list[i] - list[i - 1]; }

Problem 10

Correct the following code so that it correctly initializes and outputs the elements of the array. myList; int myList[10]; for (int i = 1; i <= 10; i++) cin >> myList; for (int i = 1; i <= 10; i++) cout << myList[i] << " "; cout << endl;

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