how to create & Storage of two-dimensional array in memory in C

Two or More dimensional arrays works on table structure, as table stores values it stores values in table like structure (rows & Column).

• A two dimensional array has two subscripts.
(More dimension More Subscripts)
• First subscript is for row and second for column.
• The syntax for declaration of two dimensional array is
data_type array[row_size][column_size];

• Consider the example int pop[5][5];

Here aa is an integer array of size 5x5
i.e. total 25 elements.

• The array elements are represented using the subscript.
• While storing in memory, each dimension of the array is indexed from zero to it’s maximum size-1.
• The first subscript indicate row and second subscript indicates column.
• For eg. Consider an integer array of size 2x3 as

int X[2][3]={10,20,30,40,50,60};


The array b is represented in memory as

Col.0 Col.1 Col.2
row0 110 120 130
row1 140 150 160

Where,
x[0][0]=110
x[0][1]=120
x[0][2]=130
x[1][0]=140
x[1][1]=150
x[1][2]=160

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!