Answer:
following are the program in C++ which is given below
Step-by-step explanation:
following are the program in C++
#include <bits/stdc++.h>
using namespace std;
int main()
{
int matrix[6][8]={{1,2,3,4,5,6,7,8},{9,10,11,12,13,14,15,16},{3,3,3,3,3,3,3,3},{4,4,4,4,4,4,4,4},{5,5,5,5,5,5,5,5},{6,6,6,6,6,6,6,6}};
cout<<"Matrix befor swapping:"<<endl;
for(int i=0;i<6;i++)
{
for(int j=0;j<8;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
for(int i=0;i<6;i++) //iterating over the loop
{
int temp=matrix[i][1];
matrix[i][1]=matrix[i][7];
matrix[i][7]=temp;
}
cout<<"Matrix After swapping:"<<endl;
for(int i=0;i<6;i++) //iterating over the loop
{
for(int j=0;j<8;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
Output
attachment are added for the above output.
following are the description of the program
1) read the matrix [i][j] by the user
2) in the loop we exchange the content of 2nd column with 5th column