2-D Array or 2-Dimensional Array are the arrays which are the collection of rows and columns. Syntax of 2-D array:- name-of-matrix[Row ...
2-D Array or 2-Dimensional Array are the arrays which are the collection of rows and columns.
Syntax of 2-D array:-
name-of-matrix[Row size][Column size];
Example:-
int add-matrix[20][30];
Programming example of 2-d matrix in C language:-
Q)Write a program to create matrix and print the matrix.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
Syntax of 2-D array:-
name-of-matrix[Row size][Column size];
Example:-
int add-matrix[20][30];
Programming example of 2-d matrix in C language:-
Q)Write a program to create matrix and print the matrix.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
void main()
{
int matrix[10][20],i,j,row,col;
clrscr();
printf("Enter row and column");
scanf("%d%d",&row,&col);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&matrix[i][j]);
}
}
printf("Matrix is");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("%d",&matrix[i][j]);
}
getch();
}}
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS