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.
Option 1: Finds the position of the largest value in a
Explanation:
Given the codes as follows:
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);
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.
An embedded computer is designed to perform a certain function and it is a component of a larger system.
An embedded computer has a dedicated function within a larger system and is incorporated as a part of a complete system rather than being a stand alone computer.
It is a microprocessor, micro controller based real time control system.
Its a combination of hardware and software that have a dedicated function to achieve a specific task. The also have peripheral devices for communication purposes.
Digital Camera
, ATM, Calculator, Digital Watch
, Self-autonomous Vehicles, Security Camera
, Washing Machine
, Mp3 player, Microwave Oven
, Fire Alarm, Smart Phone,Vending Machines, networking hardware like dedicated routers etc are examples of embedded systems.
Embedded computers are less expensive to produce, consumes less power, easier to maintain, do not require remote maintenance and easily customizable.
Synchronous data transmission is a data transfer method in which a continuous stream of data signals is accompanied by timing signals (generated by an electronic clock) to ensure that the transmitter and the receiver are in step (synchronized) with one another. The data is sent in blocks (called frames or packets) spaced by fixed time intervals.