Questions: 11 448

Answers by our Experts: 10 707

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Let's start with an easy one. Create an array that stores 4 integers. Ask the user to enter any 4 numbers, one by one. Finally, output those numbers separated by three spaces.

 

Output:


This program will ask you to enter 4 numbers. It will then confirm your entries.

Enter a number:  [user types: 1]


Enter a number:  [user types: 2]


Enter a number:  [user types: 3]


Enter a number:  [user types: 4]


Your numbers: 1  2  3  4


All values in an array must be of the same data type.


A: True.

B: False.


The C++ compiler will return an error message if you use an array subscript that is beyond the boundaries of the array.


A: True.

B: False.


Observe the following code:

 

const int SIZE = 3;

int nums[SIZE] = {1, 2, 3};

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

  std::cout << nums[i];

}

 

What is wrong with this code?


A: You cannot use constants with array definitions.

B: The initialization list exceeds the size of the array.

C: Should be i = 1 because you need to start with the first array element.

D: Should be I < SIZE so that you don't access an array element that doesn't exist.


Observe the following code:

 

int nums[3] = {1, 2, 3};

std::cout << nums;

 

What will be output to the screen?


A: 1.

B: 3.

C: 123.

D: A memory address.


Observe the following code:

 

std::cout << grades[1];

 

Which grade will be output to the screen?


A: The first grade.

B: The second grade.

C: All grades in the array.

D: Invalid code / Error.


Observe the following code:

 

int grades[5] = {0};

std::cout << grades[1];

 

What is the [1] part?


A: The Initialization List.

B: A Subscript.

C: The Size Declarator.

D: A Value.


Observe the following code:

 

int grades[5] = {0};

std::cout << grades[1];

 

What is the {0} part?


A: The Initialization List.

B: A Subscript.

C: The Size Declarator.

D: None of the above.


Observe the following code:

 

int grades[5] = {0};

std::cout << grades[1];

 

What is the [5] part?


A: The Initialization List.

B: A Subscript.

C: The Size Declarator.

D: A Value.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS