Daffodil International University

Faculty of Science and Information Technology => MCT => Topic started by: tusar.mtca on August 20, 2013, 04:49:45 PM

Title: Array in C Programing
Post by: tusar.mtca on August 20, 2013, 04:49:45 PM

In C programming, one of the frequently arising problem is to handle similar types of data. For example: If the user want to store marks of 100 students. This can be done by creating 100 variable individually but, this process is rather tedious and difficult. These type of problem can be handled in C programming using arrays. An array is a sequence of data item of same type value.
There are two types of array:
•   One Dimensional Array
•   Multi-Dimensional Array

1. One Dimensional Array:-
example:  int num[6];
[6] Specifies the number of elements to be stored in array. I can also explain this matter below this format.
A[0]   A[1]   A[2]   A[3]   A[4]   A[5]

2. Multi-Dimensional Array:-

   C programming language allows to create arrays of arrays known as multidimensional arrays.
   For example: int a[3][6];
   Here, a is an array of two dimension, which is an example of multidimensional array. This array has 3 rows and 6 columns

   Col 1    Col 2    Col 3    Col 4    Col 5    Col 6
Row 1    A[0][0]    A[0][1]    A[0][2]    A[0][3]    A[0][4]    A[0][5]
Row 2    A[1][0]    A[1][1]    A[1][2]    A[1][3]    A[1][4]    A[1][5]
Row 3    A[2][0]    1[2][1]    A[2][2]    A[2][3]    A[2][4]    A[2][5]