Skip to content

Commit 3f962a1

Browse files
authored
Update Array.md
1 parent 086f545 commit 3f962a1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Array.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1+
# Array
2+
An array is simply a number of memory locations, each of which can store an item of data of the same data type and which are all referenced through the same variable name.
13

4+
Following are the important terms to understand the concept of Array.
5+
* **Element** − Each item stored in an array is called an element.
6+
* **Index** − Each location of an element in an array has a numerical index, which is used to identify the element.
7+
8+
Array may be defined abstractly as finite order set of homogeneous elements. So we can say that there are finite numbers of elements in an array and all the elements are of same data type. Also array elements are ordered i.e. we can access a specific array element by an index.
9+
10+
## Content
11+
* [Why do we need array?](#why-do-we-need-array)
12+
* [How to declare an array?](#how-to-declare-an-array)
13+
14+
## Why do we need array?
15+
In computer programming, the most of the cases requires to store the large number of data of similar type. To store such amount of data, we need to define a large number of variables. It would be very difficult to remember names of all the variables while writing the programs. Instead of naming all the variables with a different name, it is better to define an array and store all the elements into it.
16+
17+
## How to declare an array??
18+
In C :
19+
```c
20+
dataType arrayName[arraySize];
21+
```
22+
For example:
23+
```c
24+
int a[5];
25+
```
26+
Here, we declared an array, a, of integer type. And its size is 5. Meaning, it can hold 5 integer values.
27+
28+
For Python :
29+
```python
30+
a = [1, 2, 3, 4, 5]
31+
```
32+
Declaring array in python is simple. Writing elements in square brackets can form an 1 Demensional array.

0 commit comments

Comments
 (0)