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

1..How many total elements are in an array with 4 rows and 3 columns? Select one

ID: 3871327 • Letter: 1

Question

1..How many total elements are in an array with 4 rows and 3 columns? Select one:

a. 4

b. 6

c.

12

d. 16

2..

Which statement is equivalent to the following code?

if (x > 4) {

   y = 3;

else {

   y = x;

}

Select one:

a. y = (x > 4) ? 3 : x;

b. y = (x > 4) : 3 ? x;

c. y = 3 ? (x > 4) : x;

d. y = (3 ? x) : (x > 4);

5..

vector<int> v(10);

int i = 0;

for (i = 0; /* statement goes here */ ; ++i) {

  v.at(i) = i;

}

Select one:

a. i <= v.size()

b. i < v.size()

c. i < size(v)

d. i <= 10

7..

int main () {

   int day;

   cout << “Please enter which day of the month it is: “; // A)

   cin >> day // B)

   cout << “There are “ << 31 - day << “ days left until next month.”; // C)

   return 0;

}

Select one:

a. cout << “Please enter which day of the month it is: “;

b. cin >> day

c. cout << “There are “ << 31 - day << “ days left until next month.”;

d. No errors.

8..   

What is a variable in coding?

Select one:

a. Used to denote a list of statements.

b. A row of text.

c. Represents a particular memory location.

d. Textual representation of a program.

9..

What is the output of the following code?

char myFirstInitial = ‘b’;

switch (myFirstInitial) {

   case ‘a’:

       cout << ‘A’;

   case ‘b’:

       cout << ‘B’;

   case ‘c’:

       cout << ‘C’;

   default :

       cout << ‘D’;

}

Select one:

a. BCD

b. B

c. BC

d. D

What is the output of the following code assuming the vector nums contains the values: -25, 0, 3, 15, 17, -12, and 0.

cnt = 0;

for(i = 0; i < nums.size() ; ++i) {

   if( nums.at(i) > 0 ) {

       ++cnt;

   }

}

cout << cnt << endl;

Select one:

a. 0

b. 3

c. 5

d. 7

14 .

What is the output of the following code?

int main() {

   double x = 3.0; double y = 1.9;

   cout << x / ceil(y);

   return 0;

}

Select one:

a. 1

b. 1.5

c. 2

d. 3

Taking a test please answer asap

Explanation / Answer

1) 4 rows 3 columns

4*3 = 12 elements

c) 12

2) a. y = (x > 4) ? 3 : x;

5) b. i < v.size()

7)    b. cin >> day // has error semi-colon at the end

8) d. Textual representation of a program.

9) b. BCa // it prints BCD

// first case is a it doesnot matches with a

//so it goes to case b it matches

//since there is no break all the remaining cases will perform with cases having no break

10) b. 3 // 3 positive nums>0

14) b. 1.5