Assume that scotus is a two-dimensional character array that stores the family names (last names) of the nine justices on the Supreme Court of the United States. Assume no name is longer than twenty characters. Assume that scotus has been initialized in alphabetical order. Write some code that will print each to standard output, each on a separate line with no other characters.

Respuesta :

Answer:

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

int k = 0;

while (k < 20 && scotus[i][k] != '') {

cout << scotus[i][k];

k++; }

cout << "\n"; }

Explanation:

scotus here is a two dimensional array. It contains names of 9 justices. so the loop starts from 0 and ends when i points to the last name element in the array. Then a while loop is used to check that name is longer than twenty characters and will keep on printing each output on the separate line.

Another way to write this:

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

cout << scotus[i] << "\n"; }

This loop will keep on executing and printing the names of the nine justices at every iteration until it reaches the end of the array (last element of the array scotus).