# What is One Dimensional Array in Data Structure with Example

One-Dimensional Array or single Dimensional Array is one in which only one-subscript specification is needed to specify a particular element of the array. One dimensional array we can be declared as follows:-

**Where**

**data_type**data_type is the type of element to be stored in the array**array_name**array_name specify the name of the array, it may be given any type of name like other simple variables**Expression**its specified the number of values to be stored in the array, arrays also know as subscripted values, the subscript value must be an integer value, therefore the subscript of the array starts from 0 onwards.

lets us see the example if the array declaration looks like follows:

## Example:1

1 2 3 4 |
int "a" [10] where int: data type a: array name 10: expression |

therefore, the array will store ten integer values as given above expression, its name is “a”. it can be visualized as shown given below, see and understand carefully.

Data values are dummy values, you can understand after seeing the output, indexing starts from “0”.

## Example:2

To access fourth element from array **int "a"[10]**

the fourth element = a[3]; as you can see in the given above output.

therefore, The Subscript for fourth element is 3, because the `lower bound`

of array is “0” (i.e. the array subscript starts from 0). and the `upper bound`

will be 9. hence the size of array can defined as follows:

Let’s calculate the size of array for given example, then array “a” size will be as follows:

1 2 3 |
Size of array "a" = (9-0) + 1 = 9 + 1 = 10 |

therefore, what is the meaning of the size of an array? size of the array means the number of elements that array can store base types means and type of elements that array stores such as float, integer, character.

let us understand suppose that if the declaration of an array looks like as following:

**float a[10];**

furthermore, total memory in a byte that array would occupy will be given by:

1 2 3 |
size of array = 10 x (size of float) = 10 x 4 = 40 |

`each float variable is four bytes`

there are total ten elements in the array, hence total memory array “a” occupies will be 40 bytes.

## One-Dimensional array is a Part of array

## Implementataion of one-dimensional Array in Memory

therefore, the Address of a particular element in a one-dimensional array is given by the relation address of element a

**Where**

B = The Base address of an array

w = The size of each element of an array

J = The number of required element in the array

### For Example

let the base address of the first element of the array is 4000 (i.e. base address B= 4000) and each element of the array occupies four bytes in the memory, then address of the seventh element of a one-dimensional array “a”[11] will be given as:

1 2 3 4 5 6 |
J=7 W=4 B=4000 Address of element "a"[7] = B + W x J = 4000 + 4 x 7 = 4028 |