Which set of statements totals the items in each row of two-dimensional array items, and displays each row’s total?
a.
for (int row = 0; row < items.length; row++)
{
int total = 0;
for (int column = 0; column < items[row].length; column++)
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
b.
int total = 0;
for (int row = 0; row < items.length; row++)
{
for (int column = 0; column < items[row].length; column++)
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
c.
int total = 0;
for (int row = 0; row < items.length; row++)
{
for (int column = 0; column < items[column].length; column++)
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
d.
for (int row = 0; row < items.length; row++)
{
int total = 0;
for (int column = 0; column < items[column].length; column++)
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
a.
for (int row = 0; row < items.length; row++)
{
int total = 0;
for (int column = 0; column < items[row].length; column++)
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
You might also like to view...
Which of the following function declarations will accept either cout or a file stream object as its argument?
a. void output( fstream &outFile); b. void output( ofstream &outFile); c. void output( ostream &outFile); d. void output( iostream &outFile);
Which of the following statement displays Hello World?
a. System.out.printf("%2s", "Hello " "World"); b. System.out.printf("%s %s", "Hello", "World"); c. System.out.printf("%s%s", "Hello, World"); d. System.out.printf("s% s%", "Hello", "World");