PROBLEM M5B-3: Write a complete program (Filename : ARRAY_M5B_3 ) that will load a Two-Dimensional array A[5][5] with the first 25 numbers, then print the following : a.) the content of the original array b.) the content of the array with the elements of the 2d row and 4th row interchanged. c.) the content of the array with the elements of the 3rd col and 5th col interchanged. d.) the content of the array with the 2 diagonal elements interchanged. SAMPLE OUTPUT : OUTPUT NO. 1:ORIGINAL ARRAY ELEMENTS - 1 2 3 4 5. 6 7 8. 9. 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 --- OUTPUT NO.2 : INTERCHANGE ROW 2 WITH ROW 4 ELEMENTS - -- 1 2 3 4 5 16 17 18 19 20 11 12 13 14 15 6 7 8 9 10 21 22 23 24 25 --- OUTPUT NO.3 : INTERCHANGE COL 3 WITH COL 5 ELEMENTS - --. 1 2 5 3 6 7 10 9 8 11 12 15 14 13 16 17 20 19 18 21 22 25 24 23 -.... OUTPUT NO. 4 : INTERCHANGE THE DIAGONAL ELEMENTS --> 2 3 4 1 6 9. 7 10 11 12 13 14 15 16 19 18 17 20 25 22 23 24 21 4.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Using C++, show the code for this problem

b.) ANALYSIS FOR INTERCHANGING THE 2ND ROWW AND 4TH ROW ELEMENTS :
1
2
3
4
SUBSCRIPTS FOR :
ROW 2 ELEMENTSs
ROW 3 ELEMENTS
[1 ][0]
[1 ][ 1]
[1 ][ 2]
[1 ][ 3]
[1 ][ 4]
where : j = 0 to 4
[3 ][0]
[3 ][ 1]
[3 ][ 2]
[3 ][ 3]
[3 ][ 4]
4
for( j = 0; j<= 4; j++ )
{ temp = A[1][j] ;
A[1][j] = A[3][ j];
A[3][ j] = temp;
}
A[1 ][j] TEMP A[3][j]
c.) ANALYSIS FOR INTERCHANGING THE 3RD AND 5TH COLUMN ELEMENTS :
SUBSCRIPTS FOR :
2 3
4
COL 3 ELEMENTS
[0 ][ 2]
[1 ][ 2]
[2 ][ 2]
[3 ][ 2]
[4 ][ 2 ]
COL 5 ELEMENTS
[0 ][ 4]
[1][ 4]
[2 ][ 4]
[3 ][ 4]
[4 ][ 4 ]
1
X
for( i = 0; ic= 4; i++)
{ temp = A[i][2];
A[i][2] = A[i][ 4 ];
A[i][ 4] = temp;
}
A[i ][ 2]
A[i][ 4 ]
where : i=0 to 4
d.) ANALYSIS FOR INTERCHANGING THE 2 DIAGONAL ELEMENTS :
0 1 2 3 4
SUBSCRIPTS FOR :
X DIAGONAL
O DIAGONAL
1
ELEMENTS
ELEMENTS
[0 ][ 0]
[1 ][ 1]
[2 ][ 2]
[3 ][ 3]
[4 ][ 4]
[0 ][ 4]
[1 ][ 3]
[2 ][ 2]
[3 ][ 1]
[4 ][ 0]
X
4
for( i = 0, k=4; i<= 4; i++, k-- )
{ temp = A[i][i] ;
A[i][i] = A[i][k ];
A[i][k] = temp;
}
A[i ][j]
i=j
where : i = 0 to 4
j= 0 to 4
k = 4 to 0
Transcribed Image Text:b.) ANALYSIS FOR INTERCHANGING THE 2ND ROWW AND 4TH ROW ELEMENTS : 1 2 3 4 SUBSCRIPTS FOR : ROW 2 ELEMENTSs ROW 3 ELEMENTS [1 ][0] [1 ][ 1] [1 ][ 2] [1 ][ 3] [1 ][ 4] where : j = 0 to 4 [3 ][0] [3 ][ 1] [3 ][ 2] [3 ][ 3] [3 ][ 4] 4 for( j = 0; j<= 4; j++ ) { temp = A[1][j] ; A[1][j] = A[3][ j]; A[3][ j] = temp; } A[1 ][j] TEMP A[3][j] c.) ANALYSIS FOR INTERCHANGING THE 3RD AND 5TH COLUMN ELEMENTS : SUBSCRIPTS FOR : 2 3 4 COL 3 ELEMENTS [0 ][ 2] [1 ][ 2] [2 ][ 2] [3 ][ 2] [4 ][ 2 ] COL 5 ELEMENTS [0 ][ 4] [1][ 4] [2 ][ 4] [3 ][ 4] [4 ][ 4 ] 1 X for( i = 0; ic= 4; i++) { temp = A[i][2]; A[i][2] = A[i][ 4 ]; A[i][ 4] = temp; } A[i ][ 2] A[i][ 4 ] where : i=0 to 4 d.) ANALYSIS FOR INTERCHANGING THE 2 DIAGONAL ELEMENTS : 0 1 2 3 4 SUBSCRIPTS FOR : X DIAGONAL O DIAGONAL 1 ELEMENTS ELEMENTS [0 ][ 0] [1 ][ 1] [2 ][ 2] [3 ][ 3] [4 ][ 4] [0 ][ 4] [1 ][ 3] [2 ][ 2] [3 ][ 1] [4 ][ 0] X 4 for( i = 0, k=4; i<= 4; i++, k-- ) { temp = A[i][i] ; A[i][i] = A[i][k ]; A[i][k] = temp; } A[i ][j] i=j where : i = 0 to 4 j= 0 to 4 k = 4 to 0
PROBLEM M5B-3: Write a complete program (Filename : ARRAY_M5B_3 ) that will load a
Two-Dimensional array A[5][5] with the first 25 numbers, then print the following :
a.) the content of the original array
b.) the content of the array with the elements of the 2nd row and 4th row interchanged.
c.) the content of the array with the elements of the 3d col and 5h col interchanged.
d.) the content of the array with the 2 diagonal elements interchanged.
SAMPLE OUTPUT :
OUTPUT NO. 1: ORIGINAL ARRAY ELEMENTS -
1
2
3
4
5
6.
7
8
9.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<----- OUTPUT NO.2 : INTERCHANGE ROW 2 WITH ROW 4 ELEMENTS
--->
1 2 3 4 5
16
17
18
19
20
11
12
13
14
15
6
7
8
10
21
22
23
24 25
<---...- OUTPUT NO.3 : INTERCHANGE COL 3 WITH COL 5 ELEMENTS
1
2
5
4
3
6.
7
10
9.
8
11
12
15
14
13
16
17
20
19
18
21
22
25
24
23
<----- OUTPUT NO. 4: INTERCHANGE THE DIAGONAL ELEMENTS ----->
4
1
9
8.
7
10
11
12
13
14
15
16
19
18
17
20
25
22
23
24
21
2.
Transcribed Image Text:PROBLEM M5B-3: Write a complete program (Filename : ARRAY_M5B_3 ) that will load a Two-Dimensional array A[5][5] with the first 25 numbers, then print the following : a.) the content of the original array b.) the content of the array with the elements of the 2nd row and 4th row interchanged. c.) the content of the array with the elements of the 3d col and 5h col interchanged. d.) the content of the array with the 2 diagonal elements interchanged. SAMPLE OUTPUT : OUTPUT NO. 1: ORIGINAL ARRAY ELEMENTS - 1 2 3 4 5 6. 7 8 9. 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <----- OUTPUT NO.2 : INTERCHANGE ROW 2 WITH ROW 4 ELEMENTS ---> 1 2 3 4 5 16 17 18 19 20 11 12 13 14 15 6 7 8 10 21 22 23 24 25 <---...- OUTPUT NO.3 : INTERCHANGE COL 3 WITH COL 5 ELEMENTS 1 2 5 4 3 6. 7 10 9. 8 11 12 15 14 13 16 17 20 19 18 21 22 25 24 23 <----- OUTPUT NO. 4: INTERCHANGE THE DIAGONAL ELEMENTS -----> 4 1 9 8. 7 10 11 12 13 14 15 16 19 18 17 20 25 22 23 24 21 2.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY