Answer to Question #214170 in C++ for Jaguar

Question #214170

QUESTION 3 

 

Considering the following declarations: 

const int NUMELS 10; 

int values[NUMELS]; 

Which of the following C++ statements correctly outputs the seventh element of the array? 

1. cout << values << 7; 

2. cout << values[6]; 

3. cout << values[7]; 

4. cout << values[8]; 

QUESTION 4 

Consider the following declarations: 

const int ARRAYSIZE = 7; 

float length[ARRAYSIZE] = {7.8, 6.4, 4.9, 11.2};

What is the value of length[1] and length[4]? 

1. 7.8 and 11.2, respectively 

2. 6.4 and 11.2, respectively 

3. 7.8 and 0, respectively 

4. 6.4 and 0, respectively 


1
Expert's answer
2021-07-06T02:09:51-0400

Question 3

2. cout << values[6];  since indexing in arrays start with 0. So the index of the seventh element will be 7-1 = 6. Therefore, seventh element is values[6]

Question 4

Answer is:  6.4 and 0, respectively 

The indexing in array start at 0.Therefore, the length[1] will be the second element in the array.


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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS