for(int i=0;i<3;i++) { for (int j=0;j<=i;j++) { if(i==j) { cout<<"the diagonal elements are"<<a[i][j]; } } }
Leave a comment: