Assume that scotus is a two-dimensional character array that stores the family n
ID: 3931349 • Letter: A
Question
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 soutRobertsThe value of sout is incorrect.
ThomasThe value of sout is incorrect.
AlitoThe value of sout is incorrect.
Explanation / Answer
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