Storage of two-dimensional array in memory in C

• A two dimensional array has two subscripts.
• First subscript is for row and second for column.
• The syntax for declaration of two dimensional array is
data_type arr[row_size][column_size];
• Consider the example int aa[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 b[2][3]={10,20,30,40,50,60};
The array b is represented in memory as

Col.0 Col.1 Col.2
row0 10 20 30
row1 40 50 60

Where,
b[0][0]=10
b[0][1]=20
b[0][2]=30
b[1][0]=40
b[1][1]=50
b[1][2]=60

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!!!