answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What is the representation of the third element in an array named a?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which accepts an integer array of size n and prints every third value of the array?

You can loop through the array, and print out every third element. If the index used for looping is called "i", you can test whether "i" is a multiple of three (i % 3 == 0). Or, and perhaps more efficiently, you can increase the index 3 at a time, for example: for (i = 0; i <= theArray.length, i+=3) { ... }


How do you find the HCF of all the numbers in an array java?

I guess you mean the highest common factor. Use a loop. Start assuming that the hcf is the first number in the array. Call this "result". Find the hcf of "result" and the second element, assign this to "result". Find the hcf of "result" and the third element, and copy this back to result, etc.


Why you use loop in arrays in c plus plus?

We use loops with arrays because it's one the simplest methods of traversing an array. since each element in an array is the same size, every element can be access via an offset from the start of the array, using the array suffix operator []. Arrays employ zero-based offsets because the first element is always at the same address as the array itself. Thus the first element is at offset [0], while the third is at offset [2]. What this means is that if we multiply the size of an element by its offset index, we can determine the address of that element and therefore access that element's value. The subscript operator does this for us automatically, thus giving us constant-time random access to any element in the array. We can also use pointers to manually calculate the address of an element (which is what actually goes on behind the scenes). However, when we wish to traverse the array, one element at a time, a loop is the simplest method of doing so. The loop simply iterates through all the offset indices, beginning with offset 0, then 1, and 2, and so on. The final index is always 1 less than the number of elements in the array, because arrays are zero-based.


How is an one dimensional array is represented in memory?

Arrays are allocated as a contiguous block of memory divided into one or more elements of equal size and type. Knowing the start address of the array makes it possible to reference any element within the array through a zero-based index. Multiplying the index by the size of an element determines the offset from the start of the array.


What are 3 different ways to implement an array of order 4x8?

An array of order 4x8 can either be implemented as a one-dimensional array of order 32 or as a one-dimensional array of order 4, where each element is a one-dimensional array of order 8. In either case, the 32 data elements are allocated contiguously and there is no difference in performance. A third way is to implement the one-dimensional array of order 4 as an array of pointers to separately allocated one-dimensional arrays of order 8. The order 4 array is contiguous as are the order 8 arrays, however they need not be contiguous with one another other. This is the least efficient implementation due to the additional level of indirection required to navigate the array.

Related questions

How can two single dimensional array values be stored in a third single dimensional array?

You need to create a new array with enough elements to cater for both arrays. Thus if the first array has 10 elements and the second has 5, you must create a 15 element array to store both. You then copy elements from the first array into the third and immediately follow with the elements from the second. Note that the first two arrays must be of the same type. You cannot combine an array of numeric values with an array of strings, for instance.


Why in c plus plus index always start with 0?

C++ array indices are zero-based because the first element in any array is offset 0 elements from the start address. The second element is offset by 1 element and the third by 2 elements, and so on. To put it another way, the index refers to the number of elements that come before the desired element. The first element has zero elements before it, so it is index 0. For an array of n elements, the last element is at index n-1.


Which accepts an integer array of size n and prints every third value of the array?

You can loop through the array, and print out every third element. If the index used for looping is called "i", you can test whether "i" is a multiple of three (i % 3 == 0). Or, and perhaps more efficiently, you can increase the index 3 at a time, for example: for (i = 0; i <= theArray.length, i+=3) { ... }


How 3d arrays are represented in memory?

All multi-dimensional arrays are represented as arrays of arrays. That is, each element of the array is itself an array. Thus a two-dimensional array can be thought of as being a one-dimensional array where every element is a one-dimensional array. A three-dimensional array is therefore a one-dimensional array of two-dimensional arrays. And so on. The actual memory layout of a multi-dimensional array is no different to that of a one-dimensional array of the same size: int a[12]; int b[3][4]; Assuming a 4-byte int, the amount of memory allocated to a is 12 x 4 = 48 bytes. The array b is essentially an array where each element holds an array of 4 integers, thus each element is 16 bytes in length. Given there are 3 such elements in total, the total size of b is 3 x 16 = 48 bytes, the same as was allocated to a. Although the allocations are exactly the same in terms of size, the layouts differ. The array a is an array of twelve 4-byte elements (of type int) whereas array b is an array of three 16-byte elements, each of which is itself an array of four 4-byte elements (of type int). This changes the way we refer to the individual elements of the array. Every element in an array is referred to by its offset address from the start of the array. This is determined by multiplying its zero-based index by the element size. In the case of a, every element is 4-bytes in length, thus element a[2] refers to the element that is offset 2 x 4 = 8 bytes from the start of the array. But in the case of b, however, b[2] would refer to the 16-byte element that is offset 2 x 16 = 32 bytes from the start of the array. Given that we're actually referring to an element which is itself a 4-element array, we must use a second subscript to refer to the elements of that array. Thus b[2][3] would refer to the integer that is offset 3 x 4 bytes from the start of the array referred to by b[2]. Extending this idea into three-dimensions is simply a matter of taking a third subscript into account.


How do you find the HCF of all the numbers in an array java?

I guess you mean the highest common factor. Use a loop. Start assuming that the hcf is the first number in the array. Call this "result". Find the hcf of "result" and the second element, assign this to "result". Find the hcf of "result" and the third element, and copy this back to result, etc.


Why you use loop in arrays in c plus plus?

We use loops with arrays because it's one the simplest methods of traversing an array. since each element in an array is the same size, every element can be access via an offset from the start of the array, using the array suffix operator []. Arrays employ zero-based offsets because the first element is always at the same address as the array itself. Thus the first element is at offset [0], while the third is at offset [2]. What this means is that if we multiply the size of an element by its offset index, we can determine the address of that element and therefore access that element's value. The subscript operator does this for us automatically, thus giving us constant-time random access to any element in the array. We can also use pointers to manually calculate the address of an element (which is what actually goes on behind the scenes). However, when we wish to traverse the array, one element at a time, a loop is the simplest method of doing so. The loop simply iterates through all the offset indices, beginning with offset 0, then 1, and 2, and so on. The final index is always 1 less than the number of elements in the array, because arrays are zero-based.


What is the element which belongs to the third group and third period?

There is no such element.


How is an one dimensional array is represented in memory?

Arrays are allocated as a contiguous block of memory divided into one or more elements of equal size and type. Knowing the start address of the array makes it possible to reference any element within the array through a zero-based index. Multiplying the index by the size of an element determines the offset from the start of the array.


What are 3 different ways to implement an array of order 4x8?

An array of order 4x8 can either be implemented as a one-dimensional array of order 32 or as a one-dimensional array of order 4, where each element is a one-dimensional array of order 8. In either case, the 32 data elements are allocated contiguously and there is no difference in performance. A third way is to implement the one-dimensional array of order 4 as an array of pointers to separately allocated one-dimensional arrays of order 8. The order 4 array is contiguous as are the order 8 arrays, however they need not be contiguous with one another other. This is the least efficient implementation due to the additional level of indirection required to navigate the array.


What is the first element that need a third shell?

It is sodium Chlorine is the first element that needs a third shell.


What element is the 3rd element?

lithium is the third element. It is placed in group-1


What is Array in Programming C?

Arrays allow similar types of data to be stored within a contiguous block of memory such that every data element is accessible in constant time, regardless of its physical location within the array. This is achieved through simple pointer arithmetic treating each element as a memory offset from the start of the array. Since every element is the same length (in bytes), locating any element is simply a matter of calculating its offset from its index. Indices are zero-based thus the third element can be found at index 2. The memory offset for that element is therefore the product of the element size and 2. However, C permits indices to be specified directly, while the pointer arithmetic is done in the background. Thus array_name[2] automatically returns a reference to the third element. Arrays with large and complex variable length data elements need to store those elements separately from the array, usually non-contiguously. This is achieved by using a pointer array. Pointer arrays are particularly useful when sorting extremely large data lists as it is much easier and more efficient to implement a sorting algorithm with an array than it is with a linked list, particularly when constant-time random-access is essential to the algorithm. The time and effort in building the array is generally more than compensated for by the efficiency of the algorithm. Arrays can also be divided and subdivided to better model the data they represent. For instance, a chessboard might be implemented as a one-dimensional array of 64 elements, however it makes more sense to model the chessboard in a two-dimensional array of 8x8 elements. Although the array is still allocated contiguously and can be thought of as being 8 rows and 8 columns, it's actually better to think of this two-dimensional array as being a one-dimensional array of 8 elements, where each element is another one-dimensional array of 8 elements. By thinking this way it makes it possible to allocate extremely large arrays in non-contiguous memory (as completely separate one-dimensional arrays) and also makes comprehension of a four-dimensional array in a three-dimensional world that much easier (unless you actually want to model time and space of course). A four-dimensional array can be thought of in a variety of ways: as being a one dimensional array of three-dimensional arrays, or as a two-dimensional array of two-dimensional arrays, or as a three-dimensional array of one-dimensional arrays, or even as a one-dimensional array of one-dimensional arrays of one-dimensional arrays of one-dimensional arrays. Whichever method you use to imagine your array is immaterial, so long as it makes sense to you that's all that really matters.