answersLogoWhite

0


Best Answer

int main()

{

int array[3][3];

int i;

for(i=0; i <9;i++)

{

printf("the element is %d\n", array[i/3][i%3]);

}

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you access 2D array elements by using single variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math
Related questions

How do you use subscripts with an array?

An array is a list of several related elements. You use the subscript to specify which element you want to access. For example, in Java you might have an array called myArray, with 10 elements (numbered from 0 to 9); myArray[3] would access the fourth element in the array. A variable may be used instead of a constant.


What is array What is difference between array and simple variable?

An array stores several values - for example, several numbers - using a single variable name. The programmer can access the individual values with a subscript, for example, myArray[0], myArray[5]. The subscript can also be a variable, for example, myArray[i], making it easy to write a loop that processes all the elements of an array, or some of them, one after another.


Is it the most efficient approach to access elements with the vector data structure?

Yes. A vector is a variable-length array but constant-time random-access is guaranteed regardless of an array's length.


What is an array and how do you create one How do you access information or elements contained in an array?

An array is:simply a collection of similar objectsHow you create one: (I think)Basically you receive or copy an image and place it in an array and assign it an mage Areray name.How you access info and elementsIt can be accessed by means of a variable name and an index.


What is the difference between an array element and a variable?

Array elements are all members of the same variable, indexed in a logical manner. variables are distinct objects which must be referred to distinctly. The main functional difference is that a program can iterate over an array without the programmer knowing the original size of the array or explicitly which member to access.


How do you access and store the elements of array?

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


If structure is arraythen an individual array element can be accessed by writing a variable?

A structure is not an array. Individual array elements are accessed through a number, called a "subscript". This subscript can be a constant, or a variable, or any expression that can be evaluated to give an integer.A structure is not an array. Individual array elements are accessed through a number, called a "subscript". This subscript can be a constant, or a variable, or any expression that can be evaluated to give an integer.A structure is not an array. Individual array elements are accessed through a number, called a "subscript". This subscript can be a constant, or a variable, or any expression that can be evaluated to give an integer.A structure is not an array. Individual array elements are accessed through a number, called a "subscript". This subscript can be a constant, or a variable, or any expression that can be evaluated to give an integer.


What is single dimentional?

A single dimension array is an array with one dimension. It is a collection in memory of one or more elements of the same type. int array[100]; declares an array of int's of size 100 elements. The elements are referenced as array[0], the first one, through array[99], the last one.


How do you calculate array elements value?

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.


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.


How do you read data from array?

Use the array suffix operator [] to access the individual elements of an array through a zero-based index.


How can you find the length of a single dimensional array in BlueJ?

array.length will return the number of elements in array.