Skip to content

Commit 4fd8a1c

Browse files
authored
Update Array.md
1 parent 6efdb54 commit 4fd8a1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Array.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Array may be defined abstractly as finite order set of homogeneous elements. So
1414
## Why do we need array?
1515
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.
1616

17+
## Advantages of array
18+
* Array provides the single name for the group of variables of the same type therefore, it is easy to remember the name of all the elements of an array.
19+
* Traversing an array is a very simple process, we just need to increment the base address of the array in order to visit each element one by one.
20+
* Any element in the array can be directly accessed by using the index.
21+
1722
## How to declare an array??
1823
```c
1924
dataType arrayName[arraySize];
@@ -55,3 +60,15 @@ Suppose you declared an array a as above. The first element is a[0], the second
5560
```c
5661
printf(“%d\n”,a[0]);
5762
```
63+
64+
## Basic operation on array
65+
Following are the basic operations supported by an array.
66+
67+
### Traversing
68+
This operation is to traverse through the elements of an array.
69+
70+
Following program traverses and prints the elements of an array:
71+
72+
```c
73+
74+
```

0 commit comments

Comments
 (0)