Answer to Question #214180 in C++ for Jaguar

Question #214180

QUESTION 17

Suppose that sales is an array of 50 elements of type float. Which of the following correctly initializes the array 

sales?

1. for (int 1 = 1; j <= 49; j++)

sales[j] = 0; 

2. for (int j = 1; j <= 50; j++)

sales[j] = 0; 

3. for (int j = 0; j <= 49; j++)

sales[j] = 0.0; 

4. for (int j = 0; j <= 50; j++)

sales[j] = 0.0;

QUESTION 18 

Suppose that list is an array of 10 elements of type int. Which of the following codes correctly outputs all the elements 

of list? 

1. for (int j = 1; j < 10; j++) 

cout << list[j] << " "; 

cout << endl; 

2. for (int j = 0; j <= 9; j++) 

 cout << list[j] << " "; 

cout << endl; 

3. for (int j = 1; j < 11; j++) 

 cout << list[j] << " "; 

cout << endl; 

4. for (int j = 1; j <= 10; j++) 

 cout << list[j] << " "; 

cout << endl;


1
Expert's answer
2021-07-11T14:40:18-0400

Solution 17: Option [3] is the corect answer.


for (int j = 0; j <= 49; j++)

sales[j] = 0.0; 


Slolution 18: Option [2] is the correct option.

2. for (int j = 0; j <= 9; j++) 

 cout << list[j] << " "; 

cout << endl; 


However, the above statement should be written more correctly as below:

2. for (int j = 0; j <= 9; j++) 

{

 cout << list[j] << " "; 

cout << endl; 

}



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