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
Vladimir [108]
3 years ago
7

What does the following loop do?int[] a = {6, 1, 9, 5, 12, 3};int len = a.length;int x = 0;for (int i = 1; i < len; i++)if (a

[i] > a[x]) x = i;System.out.println(x);1. Finds the position of the largest value in a.2. Sums the elements in a.3. Finds the position of the smallest value in a.4. Counts the elements in a.
Computers and Technology
1 answer:
Marat540 [252]3 years ago
8 0

Answer:

Option 1: Finds the position of the largest value in a

Explanation:

Given the codes as follows:

  1.        int[] a = {6, 1, 9, 5, 12, 3};
  2.        int len = a.length;
  3.        int x = 0;
  4.        for (int i = 1; i < len; i++)
  5.        {
  6.            if (a[i] > a[x])
  7.                x = i;
  8.        }
  9.        System.out.println(x);

The code is intended to find a largest value in the array, a. The logic is as follows:

  • Define a variable to hold an index where largest value positioned. At the first beginning, just presume the largest value is held at index zero, x = 0. (Line 3)
  • Next, compare the value location in next index. If the value in the next index is larger, update the index-x to the next index value (Line 4 - 8). Please note the for-loop traverse the array starting from index 1. This is to enable the index-1 value can be compared with index-0 and then followed with index-2, index-3 etc.
  • After completion of the for-loop, the final x value will be the index where the largest value is positioned.
  • Print the position of the largest value (Line 10)

You might be interested in
PLEASE HELP ME !!!!
Sedaia [141]

Answer:

Complete the ZipZapZop()

function so that it requests an integer from the user. The function should display a response following this pattern:

• Divisible by 3: zip

• Divisible by 5 zap

• Divisible by 7 zop

Otherwise, just display the number

Note 1 numbers that are divisible by more than one (3, 5, or 7) should contain

all applicable terms.

Notes 2 Note that you are displaying directly from this function, not returning a value to the calling function.

Hint: The number only prints if it is not divisible by ALL of 3,5,or 7

Explanation:

3 0
3 years ago
What is the name of the process of checking the client's production environment to ensure software and hardware compatibility wi
zzz [600]

Answer:

Explanation:

It is known as software testing

6 0
3 years ago
Read 2 more answers
Choose the correct answer base on the Components of Computer System
kondor19780726 [428]
1 - b - Excel is a computer program, so it'd be Software
2 - a - Process of elimination, haven't heard of the term 'peopleware' before.
3 - d - A joystick accepts input from a user to interact with a computer. ex. Flight Simulators
4 - c - A monitor will display (or output) an image based on what is received from the computer.
4 0
3 years ago
When multiple frames arrive at the same location at the same time resulting in a garbled signal is called what?
Inessa05 [86]

Answer:

A

Explanation:

because there are multiple frames

4 0
3 years ago
What is the “framing” guideline for photography? What are some ways of framing within a photograph?
Anika [276]
 Framing in photography is one way of covering the other parts of the subject. Framing gives the photo some context, depth and layers and make the image as the main focal point.
4 0
3 years ago
Other questions:
  • B. Find Addition of Binary Numbers: 1100112 + 11012
    11·1 answer
  • When you see a yield sign what do you do?
    8·1 answer
  • Organizational independence in the processing of payroll is achieved by functional segregations that are built into the system.
    6·1 answer
  • 1. Before operating any power tool, you need to
    14·1 answer
  • When writing an algorithm, the step after carrying out your plan is "sharing results."
    5·2 answers
  • WILL MARK BRAINILY!!
    9·2 answers
  • What game is this? help mee?
    8·2 answers
  • Which IDEs support multiple high-level programming languages? Select all that apply.
    13·1 answer
  • A security event popped up, alerting security of a suspicious user gaining access to, and copying files from, the %systemroot%\n
    11·1 answer
  • When does if(x==y) execute?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!