1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
insens350 [35]
3 years ago
9

What is the printout (display) of the following program? public class Test { public static void main(String[] args) { int[][] va

lues = {3, 4, 5, 1}, {33, 6, 1, 2}; int v = values[0][0]; for (int row = 0; row < values.length; row++) for (int column = 0; column < values[row].length; column++) if (v < values[row][column]) v = values[row][column]; System.out.print(v); } }
Computers and Technology
1 answer:
vodka [1.7K]3 years ago
8 0

Answer:

The printout of the program is 33

Explanation:

Given the code as follows:

  1.        int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}};
  2.        int v = values[0][0];
  3.        for (int row = 0; row < values.length; row++)
  4.            for (int column = 0; column < values[row].length; column++)
  5.                if (v < values[row][column])
  6.                    v = values[row][column];
  7.                System.out.print(v);

The code above will find the largest value from the two-dimensional array and print it out.

The logic of finding the largest value is as follows:

  • Create a variable, <em>v</em>, to hold the largest number (Line 2). At the first beginning, we simply set the value from the first row and first column (values[0][0])  as our current largest value.
  • Next, we need to compare our current largest value against the rest of the elements in the two dimensional array.
  • To make the comparison, we need a two-layers for loops that will traverse through every row and column of the array and compare each of the element with the current largest value (Line 3-6).
  • If the current largest value, v, is smaller than any element of the array, update the <em>v</em>  to the latest found largest value (Line 5-6).
  • After completion of the for-loop, the v will hold the largest number and the program will print it out (Line 8).
You might be interested in
Write a brief explanation of the problems that can occur in each of the following scenarios and what you should do to avoid thes
photoshop1234 [79]
1. Horsing around can lead to breaking equipment in the classroom or somebody getting hurt

2. leaving your backpack on the floor can cause someone to fall

3.something unexpected may happen and worsen the problem

4. it can corrupt the computer's files and deleted unsaved work.

if you want the sentences to be longer, add some words to them and make the message the same.
4 0
3 years ago
Read the excerpt below and answer the question.
zysi [14]

Answer:

Agreed

Explanation:

8 0
3 years ago
In Python, how would you print the first 4 characters of "Help me pass!"
Semenov [28]

Answer:

sample_str = "Help me pass!"

first_chars = sample_str[0:4]

print('First four character: ', first_chars)

Explanation:

sample_str = "Help me pass!"

first_chars = sample_str[0:4]

H has index 0, e has index 1, l has index 2, p has index 3. the space has an index as well, etc.

7 0
2 years ago
_____ is confirming the significance of what another person is feeling.
il63 [147K]

Validation: Understanding and showing acceptance for another person                

4 0
3 years ago
Read 2 more answers
A technician is dispatched to install additional RAM in a computer. The technician unplugs the system from the power source, and
xz_007 [3.2K]

Use an anti-static bag to hold the RAM while installing.

6 0
3 years ago
Other questions:
  • Write a Java program to print the result in the series 10, 15, 20, 25, ..., 50. Hint: You can use an iteration statement for wri
    9·1 answer
  • Can anybody come up with a catchy title for this?
    11·1 answer
  • How does a firewall provide network security
    8·1 answer
  • What is the role of the osi application layer? provides control of all the data flowing between the source and destination devic
    5·1 answer
  • Write an if statement that assigns 100 to x when y is equal to 0.
    7·1 answer
  • Explain the components of Information System?​
    13·1 answer
  • What is the mass of a cookbook
    7·1 answer
  • In the space provided, analyze the pros and cons of becoming a member of an artistic guild. Your answer should be at least 150 w
    12·1 answer
  • Difference between automated testing and manual testing
    13·1 answer
  • The success criteria are used to judge whether a project is successful. False True <br> need it now
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!