Print Matrix 2 Dimensional array – C Program

Input Matrix C Program

Write a c program for input 2 dimensional array matrix.

Is we are talking about 2 dimensional array, then the matrix is the best example of two dimensional array. For input matrix we have to consider row size and column size of matrix.

#include <stdio.h>
#include <conio.h>

void main()
{
 int a[5][5], i, j, row, col;

printf("Enter the row size of matrix : \n");
scanf("%d",&row);

printf("Enter the column size of matrix : \n");
scanf("%d",&col);

printf("Enter the elements of matrix :\n");
for(i=0;i<row;i++)
{
  for(j=0;i<col;j++)
    {
      scanf("%d", &a[i][j]);
    }

}    

printf("The Inputed matrix is : \n")
for(i=0;i<row;i++)
{
  for(j=0;i<col;j++)
    {
      printf("%d", a[i][j]);
     printf("\t");  
    }
 printf("\n");  
}    
}

The matrix c program out put is :

Enter the row size of matrix :
3
Enter the column size of matrix :
3

Enter the elements of matrix :
1
2
3
4
5
6
7
8
9

The The Inputed matrix is :
1 2 3
4 5 6
7 8 9

 

Author: Meera Academy

Leave a Reply

Your email address will not be published. Required fields are marked *