Seminar - Array
Seminar - Array
Data Structure
Introduction to Arrays
• Data Structure is a format for organizing and storing data
• Data is represented with the help of characters such as alphabets (A-
Z,a-z),(0-9) or special characters (+,-,*,/,<,>,= etc.) digits
Eg: Eman ruoy si tahw
• Information is organized or classified data, which has some
meaningful values for the receiver.
Eg: What is your name
• An Array is a data structure containing a number of data values (all of
which are same type)
• Array is a sequenced collection of related data items that share a
common name. For example we can use an array name “salary” to
represent a set of salaries of group of employees in an organization.
We can refer the individual salary by writing a number called INDEX
after the Array Name. The complete set of values is referred to as an
Array, individuals are called elements of array. The ability to use
single name to represent a set of values & to refer to an item by
specifying the item number enables us to develop concise and efficient
programs.
Classification of Array
• One Dimensional Array
• Multi Dimensional Array
One Dimensional Array
• A one-dimensional array stores elements of the same data type in
contiguous memory locations. Each element is identified by its index
or position within the array.
• Declaration : data_type array_name[array_size];
Eg) int arr[10]; (Declaring a 1D array of size 10)
• Initialization :
1. Compile time : int arr[5] = {1,2,3,4,5};
2. Run time : int arr[5];
for(int i=0;I<5;i++)
{scanf(“%d”, &a[i]) ;
}
Accessing Elements : array_name[index];
Eg) 10 11 12 13 14
arr
arr[1]; it will access 11
Multidimensional Arrays
• Two Dimensional Array : A two-dimensional array (often called a 2D
array) is an array of arrays. It’s like a table with rows and columns,
where each cell can store da
• Declaration : data_type array_name[rowsize][columnsize];
Eg) int mat[3][4];
• Initialization :
• The declaration of n-dimensional Array takes the following form :
data_type array_name[size1][size2].... [size n];