answersLogoWhite

0

How does an array look like?

Updated: 8/11/2023
User Avatar

Wiki User

11y ago

Best Answer

An array is simply a collection of more than one item of the same type. For instance, if you wanted an array of 10 ints, you would say...

int myInt[10];

... and you would refer to them as myInt[0], myInt[1], ..., myInt[9]. Note that the index starts at 0 and goes to one less than the declared size. It is an error to refer to an array element outside of the declared region.

Similarly, an array of arrays, could be declared as...

int myInt[10][20];

... and you would refer to them as myInt[0][0] through myInt[9][19]. Note that there is no comma, and that the brackets surround each index separately.

You can extend this arbitrarily, such as...

int myInt[5][6][7][8][9][10]

... just keep in mind that that represents 151,200 elements, potentially a lot of memory, though most modern platforms will not have a problem with that.

Nothing stops you from declaring arrays of anything, even of structures and classes (in C++).

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does an array look like?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.


What is meant by irregular dimensional array?

An irregular dimensional array is a special type of multi-dimensional array.First we must understand that a multi-dimensional array is just an array of arrays. Each element in the array is, itself, an array of elements.A regular multi-dimensional array will be an array of size n, with each element containing a separate array of size m. That is, each sub-array has the same size.An irregular multi-dimensional array will be a multi-dimensional array in which each sub-array does not contain the same number of elements.Regular array:array[0] = new array{0, 1, 2}array[1] = new array{3, 4, 5}array[2] = new array{6, 7, 8}array[3] = new array{9, 10, 11}This regular array is an array of size 4 in which each sub-array is of size 3.Irregular array:array[0] = new array{0, 1, 2}array[1] = new array{3, 4}array[2] = new array{5, 6, 7}array[3] = new array{8, 9, 10, 11}This irregular array is an array of size 4 in which the size of each sub-array is not the same.


How do you swap two adjecent no in array in c?

Option 1) Use a temporary variable: int x = array[i]; array[i] = array[i+1]; array[i+1] = x; Option 2) Use bit operators: array[i] ^= array[i+1] ^= array[i];


How do you swap rows in 2 dimensional array in Java?

[]temp = array[1] array[2]=array[1] array[1]=[]temp


What is the array function in CAD?

there r 2 types of array in cad - rectangular array and polar array...........

Related questions

what does 14 x 1 look like in an array?

1 row of 14 dots


What is a array in math?

An array is a computer science equivalent of a vector in mathematics. Both contain a list of data.


What does an array look like in math?

A row of numbers, a column of numbers or a rectangular layout of numbers.


What is an associative array?

An associative array is one of a number of array-like data structures where the indices are not limited to integers.


How do you empty an array in PHP?

To empty an array in PHP you need to use the unset function like shown below: <?php $array = array('hello', 'hi', 'weee'); unset($array); // empty ?>


How does two dimensional array differ from single dimensional array?

A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.


How can you mix up the order of values in a PHP array?

To shuffle an array in PHP is easy to do, all you need to use is the shuffle() function like shown below: <?php $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); shuffle($array); // array results will be randomly shuffled ?>


How do you change 'hElLo WoRlD' to 'HeLlO wOrLd' in PHP?

The process will work similar to a cryptoquip. First, you need to set up a conversion array. Then, run a strtr() and make the conversion into a new string. The code will look something like this: $input = "hElLo WoRlD"; $convert = array('A' => 'a', 'B' => 'b' ... ... 'Z' => 'z', 'a' => 'A' ... ... 'y' => 'Y', 'z' => 'Z'); $output = strtr($input, $convert); You can also look into generating the array by other means, such as looking through char codes. It is important to make sure that the array keys are the start letters and the array values are the end letters. It does not matter in what order you populate the array, as long as all letter pairs (upper-to-lower and the other way too) are present.


Where to find coupons for groceries online?

The retailmenot website offers a vast array of discount coupons for popular groceries. You might also like to have a look at the Coolsavings and Smartsource websites.


Argument Array in java script?

There is an arguments object in JavaScript. This object is treated much like an array (but it's not actually an array.)You can however reference the arguments passed to a function via this array. For instance, if we call a function like so:exampleFunc('Tom', 15, 'potato');Then we can access the value of Tom at the local variable arguments[0].


How do I draw an array to multiply a whole number and a fraction?

like this


What is the easiest way to pass arrays as argument in c?

the simple and efficient way to pass an array is pointer to an array like that int (*p)[30] ; // pointer to an array of integer having 30 element