answersLogoWhite

0

How do you calculate array elements value?

Updated: 8/20/2019
User Avatar

Wiki User

7y ago

Best Answer

You don't need to calculate an array element's value. An array element is a variable and like any variable you can access its value directly. There is nothing to calculate:

int a[5] {0, 2, 4, 6, 8};

int x = a[2]; // x=4

The only thing that really needs calculating is the index of the element you wish to access. If you know the index, then there's nothing to calculate.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you calculate array elements value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What happens if a subscript value is negative or higher than the number of elements in an array?

It cannot be part of the array.


How do you access and store the elements of array?

#include<stdio.h> #include<conio.h> int main(void) { int a[10],i;//array declaration clrscr(); printf("\n enter the elements of array"); for(i=0;i<10;i++) scanf("%d",&a[i]); printf("\n the elements you enter into the array"); for(i=0;i<10;i++) printf("%5d",a[i]); getch(); return 0; }


How you pass array elements to a function?

Passing array elements to a function is achieved by passing the individual elements by reference or by value, just as you would any other variable. However, passing the entire array requires that you pass a pointer-to-pointer to the array along with the dimension(s) of the array.


What restriction must be satisfied by all of the data items represented by an array?

An array is a group of related items that share a common name.All these elements are stored consecutively. An array must be declared before its use in the program. Array size must be specified All Array elements must be assigned to any value for assignment the value. Partial initialization of elements of an array is not allowed. Size must be integer constant enclosed within square brackets The name of the array indicates starting address of an array. Each individual element of array is accessed by a subscript.


What is the default value of the array elements in an integer array?

'0' Try this: public static void main(String[] args){ } The output would be 0 even though you did not initialize any value in the int array.


When is it better to pass an entire array of data to a function rather than individual elements?

It is better to do this when the function needs to work on the entire array, rather than on individual elements. However, do not pass the array by value; always pass by reference.


What is array literal in as2?

An array literal is a comma-separated list of the elements of an array. An array literal can be used for initializing the elements of an array.


How To find a maximum number in a 2D array?

// Pseudocode int findMax( int[][] data ) { // Return if data is empty if( data.length 0 ) { return 0; } int max = data[0][0]; // Iterate through each element in the array for( int r = 0; r < data.length; ++r ) { for( int c = 0; c < data[0].length; ++c ) { // If we find a value greater than the current max, update max if( data[r][c] > max ) { max = data[r][c]; } } } return max; }


How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.


Is it necessary to read or display the elements of an array in order of its subscripts?

By no means; you can access any random array element. If you have ever seen examples which process them in order, it is because of the following: when the order doesn't matter (for example, you want to calculate the sum of all the array elements), it is easiest to process them in order.


When an array name is passed to function in c?

It 's address is received by the function . that any changes in the value of array elements in the function will result in actual change.


What is a example of a array?

An ordered array is simply an array where all elements are in sorted order: int a[] = {3, 6, 9, 10, 15, 21}; // ordered array An array can either be initialised with ordered elements or the elements may be sorted after initialisation. When inserting new elements into an ordered array, the order must be maintained.