#include<iostream>usingnamespacestd;intmain(){inta[10][10],i,j,m,n;cout<<"Enter the number of row(s) ";cin>>m;cout<<"Enter the number of column(s) ";cin>>n;if(m*n<=0||m&&n<0){cout<<"-------------------------------------------";cout<<"\nEnter the valid number of rows and columns";cout<<"\n-------------------------------------------\n";}else{cout<<"\nEnter elements for matrix A \n";for(i=1;i<=m;i++){for(j=1;j<=n;j++){cout<<"["<<i<<"]"<<"["<<j<<"]=";cin>>a[i][j];}cout<<"\n";}cout<<"Matrix A is \n";for(i=1;i<=m;i++){for(j=1;j<=n;j++){cout<<"\t"<<a[i][j];}cout<<"\n";}}return0;}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
Enter the number of row(s) -5
Enter the number of column(s) 2
-------------------------------------------
Enter the valid number of rows and columns
-------------------------------------------
kodingwindow@kw:~$ ./a.out
Enter the number of row(s) 2
Enter the number of column(s) 3
Enter elements for matrix A
[1][1]=1
[1][2]=5
[1][3]=9
[2][1]=7
[2][2]=5
[2][3]=3
Matrix A is
1 5 9
7 5 3
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?