Two-Dimensional Arrays:


So far we have discussed the array variables that can store a list of values. There could be situations where a table of values will have to be stored. Consider the following data table, which shows the value of sales of three items by four sales girls:


The table contains a total of 12 values, three in each line. We can think of this table as a matrix consisting of four rows and three columns. Each row represents the values of sales by a particular salesgirl and each column represents the values of sales of a particular item.
C allows us to define such tables of items by using two- dimensional arrays. The table discussed above can be defined in C as
                                    v[4][3]
Two-dimensional arrays are declared as follows:


Two-dimensional arrays are stored in memory, as shown in Fig.




Previous                                                                                    Next


Powered by Blogger.