Matrices are fundamental data structures in Computer science, widely used to represent two-dimensional arrays. In the C language handling matrices involves taking input from the user and printing the matrix element. In this article, we will see how we can efficiently capture matrix data from users and print the matrix.

## Table of Contents

## Matrix Input and Output in C

Taking input from a matrix and printing a matrix in C required a nested loop structure to iterate through each row and column, with this we can reach each element of the matrix.

### C Program for Matrix Input and Output

```
#include <stdio.h>
void main()
{
int row, column;
printf("Enter the number of rows ");
scanf("%d", &row);
printf("Enter the number of column ");
scanf("%d", &column);
int array[row][column];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
printf("Enter the element at position {%d,%d}", i, j);
scanf("%d", &array[i][j]);
}
}
printf("Matrix (%d*%d) entered by user -\n", row, column);
for (int k = 0; k < row; k++)
{
for (int l = 0; l < column; l++)
{
printf("%d\t", array[k][l]);
}
printf("\n");
}
}
```

### Output

*Happy Coding*

## 2 thoughts on “Matrix Input and Output in C”