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
Access is generally used to work with ________ databases.
d1i1m1o1n [39]

Answer:

access is generally used to work with relational databases

8 0
3 years ago
The output will be true no matter what the value of input A is. The output will be false no matter what the value of input A is.
anastassius [24]

Answer:

The truth table for the above cases will be:

Case 1

A      OUTPUT

0           1

1            1

Case 2

A      OUTPUT

0            0

1             0

Case 3

A     OUTPUT

0            0

1             1

Case 4

A     OUTPUT

1           0

 0           1

Explanation:

The answer is self explanatory.

6 0
4 years ago
Read 2 more answers
Find all supplier names and cities who supply expensive chairs, where expensive chairs are those whose selling price is greater
Gnesinka [82]

Answer:

select s.sname from supplier s,product p,supply su where s.s#=su.s# and p.p#=su.p# and p.p_name like 'chairs' and p.price>300

Explanation:

First of all, we need to select all the required columns from the specific tables so that the data in those columns can be display by executing this SQL query.

As the task at hand is to find all supplier names and cities who supply expensive chairs therefore we need to join three tables in order to look for the supplier name selling the highest prices.

In the above SQL query, the conditons "s.s#=su.s# and p.p#=su.p#" will join tables and the conditons "p.p_name like 'chairs' and p.price>=300" will be used to search for the chair with price greater than $300.

6 0
4 years ago
Who invented the Porsche?
horsena [70]

Ferdinand Porsche. Hoped this helped!

3 0
3 years ago
Read 2 more answers
You can Hyperlink by:
aniked [119]

Answer:

All of the above

Explanation:

I tryed them all

5 0
3 years ago
Read 2 more answers
Other questions:
  • After making a PowerPoint presentation about a new line of clothing designs, Henri notices that he used the word “gorgeous” on n
    7·1 answer
  • Which of the following items is not found on a web page?
    9·1 answer
  • The fundamental difference between a switch and a router is that a switch belongs only to its local network and a router belongs
    10·1 answer
  • The title bar displays the name of the application and file name being used in the window. it also allows you to
    14·1 answer
  • At a minimum, your vehicle insurance policy must provide coverage of
    10·1 answer
  • The Loanable Funds Market is built very similar to the Supply &amp; Demand Model. The Loanable Funds Market relates ____________
    14·1 answer
  • Internet routing:_________. A. precomputes the most efficient route and uses it to ensure rapid packet delivery. B. broadcasts a
    13·1 answer
  • When is founded by java
    7·2 answers
  • Why do you think fax machines use RLE?
    7·1 answer
  • Qn 1) Use only Python Programming language for the below question.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!