C++ Program to Inter-change the digit in 2-Dimensional array.
#include<iostream> using namespace std; int main() { int a[4][4]={4,5,6,7, 9,2,5,8, 6,7,3,4, 1,3,6,4}; int i,j,t; for(i=0;i<4;i++) { for(j=0;j<4;j+=2) { t=a[i][j]; a[i][j]=a[i][j+1]; a[i][j+1]=t; } } cout<<"\nMatrix is:="; for(i=0;i<4;i++) { cout<<endl; for(j=0;j<4;j++) cout<<"\t"<<a[i][j]; } return 0; }