changing digonals in 2 dimention array

changing digonals in 2 dimention array - }...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Q :write a C++ program that exchange diagonals in two dimensional array ? #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { int a[4] [4]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},temp ; for (int i=0;i<4;i++) { cout<<endl; for(int j=0;j<4;j++) printf("%5d",a[i][j]);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } for(i=0;i&amp;lt;4;i++) for( int j=0;j&amp;lt;4;j++) { if(i==j) { temp=a[i][j]; a[i][j]=a[i][4-j-1]; a[i][4-j-1]=temp; }} cout&amp;lt;&amp;lt;&amp;quot;\n after changing digonal&amp;quot;&amp;lt;&amp;lt;endl; for ( i=0;i&amp;lt;4;i++) { cout&amp;lt;&amp;lt;endl; for(int j=0;j&amp;lt;4;j++) printf(&amp;quot;%5d&amp;quot;,a[i][j]); }}...
View Full Document

This note was uploaded on 10/16/2010 for the course ENG 2266e taught by Professor Aliraqi during the Spring '10 term at 4.1.

Page1 / 2

changing digonals in 2 dimention array - }...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online