c programing A matrix istesically a 2dimmsionalamay maximum


c programing

A matrix istesically a 2-dimmsionalamay (maximum 100 columns Given an int matrix m rous and noolumns, write a function called display print i in the matrix format. The function prototype is given as doll void display int n, int n a complete progrm to test your

Solution

In c programing, while passing two dimensional first array dimension(row) does not have to be specified but second dimension(column) need to be specified. So in function given in the prototype is void display(int matrix[][100], int n, int m). Here is the following program for displaying matrix in matrix format. It is advised to pass the limit first then the array while passing in function.

#include <stdio.h>
void display(int matrix[][100],int n,int m){
int i,j;
for(i=0;i<n;i++){
   for(j=0;j<m;j++){
       printf(\"%d\",matrix[i][j]);
       printf(\" \");
   }
   printf(\"\ \");
}
}
int main() {
   int n,m,i,j;
   int arr[100][100];
   printf(\"Enter the size of matrix\ \");
   scanf(\"%d %d\",&n,&m);
   printf(\"Enter elements of matrix\ \");
   for(i=0;i<n;i++){
   for(j=0;j<m;j++){
       scanf(\"%d\",&arr[i][j]);
   }   }
   display(arr,n,m);
   return 0;
}

 c programing A matrix istesically a 2-dimmsionalamay (maximum 100 columns Given an int matrix m rous and noolumns, write a function called display print i in t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site