04:10 -
OOPS using C++
Write a program in C++ using a nested for loop to print the contents of a double dimensional array in matrix format.
/*Program
to print the contents of a double dimensional array in matrix format.*/
#include<iostream.h>
void
main()
{
int a[10][10]; /*two dimensional array
for matrix representation*/
int i,j;
int row,col;
cout<<”Enter row and column of a
matrix (up to 10): “;
cin<<row<<col;
cout<<”Enter the elements for the”<<row<<
“X”<<col<<” matrix : ” <<endl;
/*store
elements in two dimensional array*/
for(i=0;
i<=row; i++)/*first for loop for row*/
{
for(j=0; j<=col; j++)/*first for
loop for col*/
{
cin>>a[i][j];
}
}
/*print matrix a using nested for
loops*/
cout<<”The matrix is
:”<<endl;
for(i=0;
i<=row; i++)/*first for loop for row*/
{
for(j=0; j<=col; j++)/*first for
loop for col*/
{
cout<<a[i][j]<<”
“;
}
count<<endl;
}
}/*End
of main() function*/