Computer Science, asked by muskanparween632553, 1 month ago

Write a program to input the elements of 4 x 3 matrix and prints its
elements properly using array.

Answers

Answered by hardiksingh8b
36

Explanation:

include <stdio.h>

int main()

{

int i, j, m, n;

int matrix[10][20];

printf("Enter number of rows : ");

scanf("%d", &m);

printf("Enter number of columns : ");

scanf("%d", &n);

/* Input data in matrix */

for (i = 0; i < m; i++)

{

for (j = 0; j < n; j++)

{

printf("Enter data in [%d][%d]: ", i, j);

scanf("%d", &matrix[i][j]);

}

}

/* Display the matrix */

for (i = 0; i < m; i++)

{

for (j = 0; j < n; j++)

{

printf("%d\t", matrix[i][j]);

}

printf("\n");

}

return 0;

Answered by sourasghotekar123
8

#include<stdio.h>

int main()

{

int i,j,a[4][3];

printf("Enter elements of the matrix:\n");

for(i=0 ; i &lt; 4 ; i++ )

{

 for(j=0 ; j &lt; 3 ; j++ )

 {

  printf("a[%d][%d]=",i,j);

  scanf("%d", &a[i][j]);

 }

}

printf("The elements of the matrix are:\n");

for(i=0 ; i &lt; 4 ; i++)

{

 for(j=0 ; j &lt; 3; j++)

 {

  printf("%d\t",a[i][j]);

 }

 printf("\n");

}

}

Hence, the above is a program that allows you to input elements into a matrix and subsequently print them out.

#SPJ3

Similar questions