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

โˆ™ 2012-05-29 05:31:14
This answer is:
User Avatar
Study guides

Is Microsoft Access an RDBMS or DBMS

How might an automobile company use a management information system to reduce its costs and better serve its customers

What are PCs that are classified as mobile computers

What are the entry barriers that act as a potiential threat to new entrants in the market

See all cards
4 Reviews

Add your answer:

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

How elements of array accesses the value of variable?

Elements of an array don't access anything, but you can access the elements of an array, example: int a[10]; a[3]= 7; a[7]= 2*a[3];

How do you access and store the elements of array?

You can access and store elements in an array using a[n] where a is the name of the array and n is the location. Ex: a[5] = 100; adds the value 100 to the 5th location in the array a int i = a[5]; gets the 5th value from the array a and assigns it to the variable i which will have value 100.

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.

What is faster access the element in an array or a variable?

Arrays are variables, too. Accessing array-elements is obviously a bit slower than accessing scalars.

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 difference between an array variable and an ordinary variable?

An ordinary variable holds a single value; an array variable holds multiple values.

How is an array different from a normal variable?

An array is a collection of variables of the same type. Variable is a single value, while array is a collection.

What is Uses of array in c plus plus?

The primary use of an array is when you need constant time, random access to any element within a collection of elements of the same type. If you don't need random access, a list is more efficient when the number of elements is variable. If the number of elements is fixed, an array uses less memory.

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 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.

What is single dimentional array?

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.

People also asked