57) In C++: Suppose that list is an array of 10 components of type int. Which of
ID: 3582236 • Letter: 5
Question
57) In C++:
Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list?
for (int j = 1; j < 10; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 1; j <= 10; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 0; j <= 9; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 1; j < 11; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 1; j < 10; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 1; j <= 10; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 0; j <= 9; j++)
cout << list[j] << " ";
cout << endl;
for (int j = 1; j < 11; j++)
cout << list[j] << " ";
cout << endl;
Explanation / Answer
C is the right answer
intiger array starts with 0 the element
So in the 10 element array is
list[0], list[1], list[2],.......list[9].
for(int j=0;j<=9;j++)//loop from0 to 9
cout<<list[j]<<" "; //prints j th element and space
cout << endl;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.