Translate

Labels

Showing posts with label 2-D ARRAY TO 1-D ARRAY. Show all posts
Showing posts with label 2-D ARRAY TO 1-D ARRAY. Show all posts

Saturday, 13 July 2013

PASSING 2-D ARRAY TO A FUNCTION

There are three ways in which we can pass a 2-D array to a function.these are illustrated in the following program.

main()
{
int a[3][4]={1,2,3,4,5,6,7,8,9,8,7,6};
clrscr();
display(a,3,4);
show(a,3,4);
print(a,3,4);
}


Friday, 14 June 2013

PROGRAM TO CONVERT 2-D ARRAY TO 1-D ARRAY

#define MAXROW 3
#define MAXCOL 2
main()
{
int a[MAXROW][MAXCOL],B[MAXROW*MAXCOL];
INT I,J,K=0;
printf("Enter the matrix elements in row order\n ");
for(i=0;i<MAXROW;i++);
for(j=0;j<MAXCOL;j++);
{
scanf("%d",&a[i][j]);
b[k++]=a[i][j];
}