Assume that scotus is a twodimensional character array that

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 .

My code is

for (int i = 0; i < 9; i++)
{
   int j = 0;
   while (j < 20)
   {
       cout << scotus[i][j];
       j++;
       if(scotus[i][j] == \' \')
       {
           cout << endl;
           j++;
       }
   }
   cout << endl;
}

and

for (int i = 0; i < 9; i++)
{
   int j = 0;
   while (j <= 20 && scotus [i][j] != \' \')
   {
       cout << scotus[i][j];
       j++;
   }
   cout << endl;
}

this

And both failed. So, If anyone can answer this question, please help me. I will appreciate in advance.

Edith de Stance states:
          We think you might want to consider using: !=
          Solutions with your approach don\'t usually use: ==
          Solutions with your approach don\'t usually use: if

Want More Hints? Hear From Other Voices


Problems Detected:
          The value of sout is incorrect.

TEST CASE TABLE

Result Feedback
sout
\"redX.png\"
  Roberts  
The value of sout is incorrect.
\"redX.png\"
  Thomas  
The value of sout is incorrect.
\"redX.png\"
  Alito  
The value of sout is incorrect.

Solution

char scotus[9][20]; // this means 9 names with maximum size of 20

for (int i = 0; i < 9; i++)
{
printf(\"%s\",scotus[i]); // or else use puts(scotus[i])

}

Try this code, this will be useful to do your task

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 State
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 State

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site