Professional Documents
Culture Documents
Introduction :-
1) One-dimensional array:-
Page 1
DSM COLLEGE PARBHANI Chapter 4 : Arrays
11 22 33 44
Program :-
// program to demonstrate one d array.
#include<stdio.h>
#include<conio.h>
Void main ()
{
Int a [4];
a[0]=11;
a[1]=22;
a[0]=33;
a[2]=44;
printf(“\n %d,a[0]”);
printf(“\n %d,a[1]”);
printf(“\n %d,a[2]”);
printf(“\n%d,a[3]”);
getch();
}
Page 2
DSM COLLEGE PARBHANI Chapter 4 : Arrays
2) Two-dimensional array :-
➢ The array which having two index/subscript is called Two-dimensional
array
➢ Two -dimensional array is also called as matrix(table/tabular)
➢ Following is the syntax to declare two-dimensional array :-
Datatype array-name[size 1] [size 2];
➢ Here Datatype may int,char,float,double etc.
➢ Array-name is the name of array .
➢ Size 1 indicates how many rows.
➢ Size 2 indicates how many columns.
➢ Above statement will create following structure in memory .
A 0 1
A 0 1
55 77
0
66 88
1
Page 3
DSM COLLEGE PARBHANI Chapter 4 : Arrays
ex:-
printf(“\n %d,a[0][0]”);
printf(“\n %d,a[0][1]”);
printf(“\n %d,a[1][0]”);
printf(“\n%d,a[1][1]”);
➢ The array which having more than two indexes is called multidiamemsional
array.
➢ Following is the syntax to decleare multi diamensional array :-
Datatype array-name [size 1] [size 2] [size 3]…… [size n];
Ex:-Int a[2] [2] [2];
Following is the syntax to initialize multi-dimensional array.
Array-name [index 2] [index 2] [index 3] …….[index n]=value ;
Ex:-
a [0] [0] [0] =10;
a [0] [1] [0] =20;
a [1] [0] [0] =30;
a [1] [1] [0] =40;
a [0] [0] [1] =10;
a [0] [1] [1] =20;
a [1] [0] [1] =30;
a [1] [1] [1] =40;
Page 4
DSM COLLEGE PARBHANI Chapter 4 : Arrays
pointer :-
name a
a=10
will create following structure in memory.
value 10
a=10
P name
Page 5
DSM COLLEGE PARBHANI Chapter 4 : Arrays
value 1000
Page 6
DSM COLLEGE PARBHANI Chapter 4 : Arrays
Pointer to pointer :-
Page 7
DSM COLLEGE PARBHANI Chapter 4 : Arrays
Page 9
DSM COLLEGE PARBHANI Chapter 4 : Arrays
Page 10