CIS170C Quiz Week 5

$4.50

CIS170C Quiz Week 5
(TCO 11) Which of the following technique can be used to process the…

SKU: CIS170C Quiz Week 5 Categories: , Tags: , , , ,

Description

CIS170C Quiz Week 5

CIS170C Quiz Week 5

A+

(TCO 11) What is the value of the subscript for the first element of an array?

Undefined

1

0

Determined by the declaration of the array

(TCO 11) Which of the following technique can be used to process the elements of a single-dimensional array?

Selection structure

Looping structure

Sequence structure

None of the above

(TCO 11) Given myArray[1][5], the number 5 refers to a _____.

Row

Column

Row and a column

None of the above

(TCO 12) Given the following array:

int profit [5] = {10, 20, 31, 55, 66};

The following statement would replace which value?
profit [0] = profit[2];

10 with 31

10 with 20

20 with 31

10 with 55

(TCO 12) In the variable initialization: char course[20] = Welcome to CIS170C ; the character at course[6] will be _____.

\0

The letter m

The letter e

A space

(TCO 11) In the following table, what is the value of table[2][1]?
int table[3][4]={3,7,0,2,4,9,8,1,3,6,5,4};

4

7

6

1

(TCO 11) What type of error will this code produce?

int n[10], i;
for(i = 0; i < 10; ++i)
n[i] = i;

No compiler errors will be reported

A compiler error is generated since there are no braces {} with the for loop.

A runtime error may occur because we are out of bounds on the array.

A compiler error is generated since there are no braces {} with the for loop, AND a runtime error may occur because we are out of bounds on the array.

(TCO 11) Is it possible to write code in this manner for a C++ program?

char auto;
cout << “what kind of automobile do you have?”;
cin >> auto;
char cars[auto];

Yes, this is perfectly acceptable C++ code

No, the array dimension cannot be a variable

The compiler would report that there is an illegal use of a keyword.

Yes, this is perfectly acceptable C++ code, but the comopiler would report that there is an illegal use of a keyword

(TCO 11) What is wrong with this code?

void WriteDay(char d[]);
int main( )
{
char Day [10] = “Friday”;
WriteDay(Day[]);
return 0;
}

The brackets are not needed in the call statement

Friday is too short for the array

The code is correct as written

The call statement should be written as WriteDay(Day[10]);

(TCO 12) Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

*( tPtr + 3 )

tPtr[ 3 ]

&t[ 3 ]

*( t + 3 )

(TCO 11) Explain how a linear search is conducted to find a particular data value in an array. Provide a C++ program segment to illustrate your answer.