 Hello Learners, in the first part we have discussed the introduction of ARE and the initialization and declaration of ARE. We have also discussed why the ARE is needed, what are the terminologies associated with ARE. Now, in the second part we will discuss the types of ARE. First, the one-dimensional ARE and then the two-dimensional ARE or the multidimensional ARE. So, let us see now the one-dimensional ARE. So, one-dimensional ARE means the elements are stored in a one row. It is the simplest form of ARE and it is like a list, one-dimensional ARE is like a list and it is structured of the collection of the homogeneous data elements. Now, how we calculate the address of one-dimensional ARE? B you generally use one formula for using the address of an element in an ARE. The formula is this is AI, AI is the position that is index and B is the address of the first element that is the base address, B is the base address and then into W, what is W? W is the bytes of the memory space. For integer data types, for short integers W is 2 bytes, for character W will be 1 byte like that. Now, let us see one example here you see in this array it is the size is 10, A0 to A9. So, suppose we need to calculate the address of A5, how we calculate by using the formula A5 that is A5, so what will be the address here I will be 5. Then base is first, B is the base address, base address is 600, then B is 600 plus I into W, W is 2 bytes integer type variable, so 2. So, 600 plus I is 5, 5 to the 10, so 610. Now, see this A5 value is 610, so like this the address of an element is calculated using the formula, formula is what AI any position of an array B plus I into W. Next is how we enter the value in a one dimensional array. We can insert the value in an array in two ways, one is at the compiling time, means compiling at the time of initialization and other is the at the runtime. So, these are the two way how we can enter the values in an array. In the compiling time means we have to before the compilation we can enter the values. So, here let us see an array here array is considered of size 5, the name of the array is n. By using the printf we can define the values, so this printf d n0, 1, 2, 3, 4, so these are the value they display the value these five values it will display. Now, we can also initialize it by using the loops. So, three types of loops like while, do while and the for loop. So, now in the above example statement say the array of the elements is initialized at the time of program is written or the array is declared in the declaration time. Now, using the loop the loop may be while, do while or for loop we can define the values in the program. So, how we define suppose we use the this while loop, we need to print a the values from suppose 1 to 5 that is the program. So, how we use the while loop suppose integer n these are variable and this n equal to suppose we have defined 5, then while, while then here we write the condition or test condition while n is less than 5, then we write the body this is a body what is the body printf this is the statement n then n is n equal to n plus 1. So, in this loop the first we have to write n is 1, so yes it is less than 5, so it printed the first 1 value is printed 1 comes out then again n is n plus 1 means n is now 2 yes 2 is less than 5. So, next again 2 is printed and then again plus 3 yes it is less than 3 first n is there, so n value is 1 already it is 1. So, next do while in do while how we can write the do while condition similar cases suppose integer n n equal to 1 then do, so this is the condition where we use the do while loop. Next is the for loop how we use the for loop look at the code where we help with the help of for loop. So, here for first is i equal to 0, then i is less than 5 i plus plus then scan f it takes the value emboss and ai. Now, the array location is moved from the first element position to the last element position as there is a i 5 plus plus, so it is moved to the last element and this emboss and ai gives the address of the ith element and the element of the array where the current value is a needs to be stored. So, this will give the address of the element then how we access the values in an array. So, by using the printf command printf statement we can you access the values we shall show this by running in the C turbo C plus plus program. Then let us see one example, this example we shall discuss in the turbo C plus plus. Let us now see how to enter the values in one dimensional array. To insert values in one dimensional array there are two ways one is compiling time that is at the time of initialization of the array and the other is the run time in which the array elements are initialized after the compilation of the program. So, let us first see initialization at the time of declaration that is first method. First include stdio.h then include conio.h, so these are two header files, so header files are used to store the library functions which are help to reduce the complexity of a program void main then we are give the body of the program. So first to declare the array in deserves n is the array suppose size is 5 and we are giving the values we initialize the array at the time of declaration. So, 1, 2, 3, 4, 5 these are the elements of the array then before that I have given a command that is clear skin. So this function is used to clear the screen and another function that is gets this file gets function is used to hold the screen during run time. So these two functions are included in the conio.h header files and stdio header file is used to store the input output functions. Then after initialization we give the printf then 0 so first element of the array is in 0 position so n0 printf the second is in one position then there are five elements so we have to write five times n2 then n3 then printf n4 so since the size is 5 so last value is 4 that is i minus 1 then we close the program so you revise the program clear screen then declare the array and initialization values are given then we print means it display the values so after this you go to the compile compile control f9 you before run the program you have to compile it so one error press any key printf n is not written here so print prin t printf so again go to compile yes now zero error success press any key then go to run so yes see the output here one two three four five so these are the values we have entered in the array so next let us see the second method where we are using the loop that means initialize the array at the time of program is written that is array is declared after compilation so in that case we use the loop so different types of loops are there while do while for loop so let us see the for loop stdio.in include konio.in how it means these are fixed then clear screen gets function so first we what have to do we have to initialize the array so array is and size five so we have not given the value of the array we will give it during the runtime after compilation so we use if you use the loop so for loop you take one variable i then printf d uh no it's not required you just write entire the elements of the array so slash n it just gives the new line it displays the new line then you give the for loop for i equal to zero i less than five as the size of that is five so i less than five i plus plus so this is the way where how we write the for loop start the curly bracket then you take scanf scanf is function to which except the values in the variable d m person and i so this for loop will repeat it unless until and unless the i is uh greater than five scanf okay then we can enter now we want to see printf printf new line the array elements r slash n it will show in the new line then you give again a loop for for loop you put here you have to zero i less than five i plus plus curly bracket then print printf d uh here n i so it will print close the curly bracket now check first clear screen it is right here semicolon is not given then printf enter the elements of the array then we scanf function except the elements then again printf here semicolon is not given in for loop in the for statement there is no semicolon is required here printf yes this integer correct compile control f nine compiling success zero error then alt f nine yes first enter the values of the array we have given suppose one three six two nine so these are the five values yes the array elements are one three six two nine so what we have done first we enter the values of the array means after compilation then we display it okay here this is a assessing and entering a one-dimensional area and one thing if you are new in programming language you have to practice practice more and more times you you try to write the programs you will be expert in the program so practice is very important in the c programming so learners now we have learned the one-dimensional array how we can enter the values in the one-dimensional array and how we can access the values and also we have learned the initialization and declaration of one-dimensional array now let us see the two dimensional array so now uh two-dimensional array two-dimensional array are the collection of homogeneous data items where the elements are ordered in a number of rows and the column in one-dimensional the elements are arranged in a rows one row and in the two-dimensional it it is arranged in the row and column then two-dimensional array can be declared just as a declare of the one-dimensional array similar way we declared but one difference is there we specify the size of the column in one-dimensional we specify the size of the row but here we specify the size of the column also and how we declare it is in the two-square bracket suppose uh integer it is data type array is the variable then five is the size of the row and second one is the size of the column so this is the declaration of an two-dimensional array for character we can write this character array now please we are checking the declaration of the two-dimensional array uh see this one here uh the array name is this is the array a is the array name of the array so this size is the column and this size is the row now uh this size of the array is there are four columns so uh column is four and the three rows so size of the array will be three four and that name of the array is a then uh the first one is the first subscript this is first subscript and this one is the second subscript now uh in C language both the rows and columns are start from zero position so here first position is the zero zero and for the first row uh the row position is zero for the second row it is one third row it is two and similarly for the column position first one is zero for the all the first column and it is one for the second column two for the third and three for the fourth column now uh here the first element of the array is represent as the a zero zero next uh since we need the two subscripts that is one for one is row and the other is for column and two-dimensional it is therefore it is called the two-dimensional array now the uh storage representation the two-dimensional array can be stored in two different ways one is row wise means row order and the other is the column order so row major order what is row major order here the elements are stored in the first first row then we it is stored the second row like that uh let us see how in the row major orders uh suppose uh in the uh row that is one two three first row then it comes to the suppose uh four one two first we have stored the first row then second row then it comes to the second row it's safe again for the third row suppose it is three two zero then again comes to the next row so it is in the row order uh let us consider a nine element array these are the elements and it is the size of the array is b three three so what is the value how it is stored first it is stored one three two then again it comes four five six then seven eight nine so it is in the row order row major order next is the column major order here first uh first column are stored then it is second column then third column like that so i'm showing you here uh suppose the numbers are one two three four five six seven nine suppose eight so how it is stored first uh this column will be stored then again it goes to two fives nine it is stored in that way and then it is goes to here and then it is stored in that way so it is a column major order in two dimensional array there are two ways uh where the datas are stored uh there is a equation to find out the address address calculation for the row major order and the column major order now let us see uh here suppose b is the base address first address of the uh element and then w is the word size that is integer type it is two character one like that and uh the element the address of the element suppose i need i j b i j b is the row j is the column and the maximum row column size is m n so maximum size of the array row is number of row is m and n is the number of column then for the row major order uh the formula is like this v plus i into n plus j into w so let us check one example here uh in the row major the formula is suppose a one so here what is the address we need a one two that means the a one two this address i need suppose b is base address is let us consider 50 so this is the equations which is used to calculate the address in the row major order so now let us check one example here suppose uh this is an array a here there are five elements are there so what is the position suppose this position is zero zero uh it is a matrix of two into three here n equal to m equal to two n equal to three so row order is first is one two three then second is two one four and suppose this address is 52 by 52xt so using this formula suppose we need to find out the address of this value zero two this address means b here i equal to zero j equal to two clear now first b what is the first address base address is 50 plus i is for zero zero into n n is three plus j j is two then into w w is two so what is the value 50 plus so here zero so two into two four so equal to 54 54 so this is the address for zero two that means zero two 54 is the address clear this is the process for row major order address calculation similarly for column major order this equation is the b plus j into m plus i into w same way next we shall discuss the entering the values in the 2d array so we shall discuss this in the turbo series plus plus using the program and enter we can initialize the values in the two dimensional array like this also three row three and four columns three rows and four columns are there so this is an example for initialize the values for entering the values now insert the values into the array elements by accessing them individually we one we enter the values at a time now let us see one example where we have an integer array a b two three that is row two column three for six elements there are six elements so first is zero zero eleven zero one twenty two zero two it is a row order usually row order row major order is generally used to store the elements then b11 then b6 so this way using the loop also we can enter the values using the loop in the two dimensional array how we use the loop so there are two for loops one is for row and another one is for column two for loops are used for the first column we take this statement then assessing the values how we can assess the values similar way we can assess the values by using the printf statement let us take this program that is one example I have given here enter and assess the elements in a two dimensional array we discuss this by using the c program let us see the two dimensional array okay so for two dimensional array same method include stdio.h conio.h might mean clear escape gets now for two dimensional array we have to write integer suppose array is a so one for row first we specify the size size of the array suppose 10 and first one is for row and the second is for column this is a declaration of the array this variable name is a next we give the variables i comma j i is required for row and j is for column then we have we insert the row size suppose variable is row underscore size this is one variable then column size suppose u l underscore j d size so these are two variable next we enter the value printf give the number of row how many rows is required in the program so new line then we scan f it will take the values m person what is the variable that is row size row size okay scan f now we enter the column size printf new line enter the number of column to enter the number of column how many column is there for your array so then scan f scan f percent ht so what is the variable m person call underscore j size okay up to this step what we have done first declare the array suppose size is 10 10 array name is a then we declare the variables that is i j one is row size and row column then printf give the number of rows we put the how many rows is required then column after that now we want to enter the elements elements in the two dimensional array so for this sorry printf enter enter the elements in the array okay then we have to start the for loop for i equal to zero i less than here as we have insert the row size not this size so do it is a size 10 we will enter no in the row size variable so you give i less than row underscore size then i plus plus so this is one look inside the loop you have to write this is for row size again we have to write for column size for now j equal to zero j less than call underscore size j plus blocks this is what we call now insert the curly bracket it will take the values now scan f presentation d so what we have to do the name of the array ampersand arrays a you give first is i for row then j finish the second follow for column again you get the closing bracket of the second for loop okay so this is the way to enter the values in a two dimensional array two for loops is required one for row another for column now we want to print means access the elements so what printed you write one new line the elements elements in the array i this new line now you again write the two for loops for i equal to zero i less than row size i plus plus curly bracket for the second for loop for now j equal to zero j less than column size column size that means then j plus plus close it again start the curly bracket so what is there we have to print f print f since d so array i then j okay now suppose if you want to see the array so you give here arrays in percentage d then again percentage d so it will show the array equal to positions it will show the row and column positions then it takes the value and you just put it here our new line slash and this in new line if you want to show the position also i comma j comma then array semicolon insert a semicolon here then close the first for loop after that the second for then gets function is not written oh it's a game so you verify once again the program first header clear screen we declare the array then declare the variables give the rows then it takes the value column value let's check alt f9 there's two errors are there so let's see missing the statement semicolon oh bracket is not there the bracket here okay call size j equal to j this oh is there we correct it should be is zero right then alt f9 a success and zero error yes now go to run control f9 see give the number of rows suppose i have given how many rows three rows enter the number of columns suppose three columns okay enter the elements so three into three nine nine elements we need to enter uh one two three four five six seven eight nine six so first position the elements of the array are first zero zero position is one zero one it is a row wise row major order then it shows the column okay so these are the values in the output so what we have seen here this is a program to enter and access data elements in two-dimensional array so this is the program i think you it's clear now in the two-dimensional array how we write the programs how we enter the rows and columns i hope this video will help you to understand about the array we shall come next with another video very soon thank you very much