Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, can someone help me with some C++ questions about arrays: 1.What is not true

ID: 3598514 • Letter: H

Question

Hi, can someone help me with some C++ questions about arrays:

1.What is not true about an array?

A.elements in an array are accessed by using an integer index

B.an array can contain elements of different types

C.an array allows you to store multiple pieces of related data

D.a for loop is an excellent way to visit each element of an array

2.You have a string array named stateArray declared to hold the names of all U.S. states in alphabetical order ("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", ....).

Show the code needed to properly declare a const to be used to reference (or access) the array position for California:

Using the constant you just declared, show the code needed to reference (or access) the element that contains "California".

Ohio is the 35th state in alphabetical order. Complete this declaration of a const to access Ohio. const int OHIO =

3.

You have the following function:

void initializeArray(int arr[])
{
for (int index = 0; index < SIZEOF_ARRAY; index++)
{
arr[index] = index + 1;
}
}

You have the following code that uses that function:

int arrayOne[SIZEOF_ARRAY];

initializeArray(arrayOne);

What will be true about arrayOne when the function call is complete?

A.the elements of arrayOne will not be changed from what they were before the call

B.the elements of arrayOne will all contain 0

C.the elements of arrayOne will contain the integers 0 through SIZEOF_ARRAY - 1

D.the elements of arrayOne will contain the integers 1 through SIZEOF_ARRAY

4.

The following code will not compile becase the size of the array is not specified:

int values[] = { 1, 3, 5 };

True or False?

5.You must know the size of an array when writing your program, as it is not possible to create one dynamically at runtime.

True or False?

6.Pass by value means that

A.the memory address of the argument will be passed to the parameter variable

B.the memory address of the argument will be copied to the parameter variable

C.the value of the argument will be copied to the parameter variable

7.

You have the following integer array that contains all the odd values between 1 and 11:

const int SIZEOF_ODD = 6;

int oddValues[] = {1, 3, 5, 7, 9, 11};

Show the code needed to loop through oddValues and add 10 to each element.

Write just the statement needed to do this.  Do not include an entire program. If you do, you will receive 0 credit.

Explanation / Answer

1.What is not true about an array?

Answer: B.an array can contain elements of different types

2.You have a string array named stateArray declared to hold the names of all U.S. states in alphabetical order ("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", ....).

Answer:  

const int CALIFORNIA = 4;

stateArray[CALIFORNIA ];

Question 3

Answer: D.the elements of arrayOne will contain the integers 1 through SIZEOF_ARRAY

Question 4

The following code will not compile becase the size of the array is not specified:

int values[] = { 1, 3, 5 };

Answer: True

Question 5

5.You must know the size of an array when writing your program, as it is not possible to create one dynamically at runtime.

Answer: False

Question 6

6.Pass by value means that

Answer: C.the value of the argument will be copied to the parameter variable

7.

You have the following integer array that contains all the odd values between 1 and 11:

const int SIZEOF_ODD = 6;

int oddValues[] = {1, 3, 5, 7, 9, 11};

Answer:

for(int i=0;i<SIZEOF_ODD ;i++) {

oddValues[i] = oddValues[i]+10;

}

const int OHIO = 34;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote