#include ctr1=0; while(ctr1arr1[ctr2]) { 17 using namespace std; 18 19E int main() { int arr1[5]={30,20,50,10,40}; int n=5, ctr1, ctr2, temp; 20 21 22E 23 24E //display the original elements cout<<"Unsorted elements:"<arr1[ctr2]) { 32 } 33 //display the elements cout<

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

Implement the pseudocode of reading two dimensional array (ROW-WISE and COLUMN-WISE) into C++ program. Your program should ask for the size of the two-dim array and elements should be supplied externally by the user .

1
#include <iostream>
ctr1=0;
while(ctr1<n-1)
{
ctr2=ctr1+1;
while(ctr2<n)
17
2
using namespace std;
18
3
19 E
int main()
5日{
4
20
21
int arr1[5]={30,20,50,10,40};
int n=5, ctr1, ctr2, temp;
22 E
7
if (arr1[ctr1]>arr1[ctr2])
{
temp=arr1[ctr1];
arr1[ctr1]=arr1[ctr2];
arri[ctr2]=temp;
}
ctr2++;
}
ctr1++;
23
8.
24E
//display the original elements
cout<<"Unsorted elements:"<<endl;
for (ctr1=0; ctr1<n; ctr1++)
{
cout<<arr1[ctr1]<<" ";
}
9
25
10
26
11
12E
13
14
15
27
28
29
30
31
//sorting starts here....
ctr1=0;
while(ctr1<n-1)
{
ctr2=ctr1+1;
while(ctr2<n)
{
if (arr1[ctr1]>arr1[ctr2])
16
32
17
18
19E
33
//display the elements
cout<<endl<<"Sorted elements:"<<endl;
for(ctr1=0; ctr1<n; ctr1++)
{
cout<<arr1[ctr1]<<" ";
}
return 0;
}
34
35
20
36
21
22E
23
24B
25
37E
38
39
40
temp=arr1[ctr1];
41
Transcribed Image Text:1 #include <iostream> ctr1=0; while(ctr1<n-1) { ctr2=ctr1+1; while(ctr2<n) 17 2 using namespace std; 18 3 19 E int main() 5日{ 4 20 21 int arr1[5]={30,20,50,10,40}; int n=5, ctr1, ctr2, temp; 22 E 7 if (arr1[ctr1]>arr1[ctr2]) { temp=arr1[ctr1]; arr1[ctr1]=arr1[ctr2]; arri[ctr2]=temp; } ctr2++; } ctr1++; 23 8. 24E //display the original elements cout<<"Unsorted elements:"<<endl; for (ctr1=0; ctr1<n; ctr1++) { cout<<arr1[ctr1]<<" "; } 9 25 10 26 11 12E 13 14 15 27 28 29 30 31 //sorting starts here.... ctr1=0; while(ctr1<n-1) { ctr2=ctr1+1; while(ctr2<n) { if (arr1[ctr1]>arr1[ctr2]) 16 32 17 18 19E 33 //display the elements cout<<endl<<"Sorted elements:"<<endl; for(ctr1=0; ctr1<n; ctr1++) { cout<<arr1[ctr1]<<" "; } return 0; } 34 35 20 36 21 22E 23 24B 25 37E 38 39 40 temp=arr1[ctr1]; 41
#include <iostream>
using namespace std;
3
int main()
59 {
4
int arr1[2][3]={10,20,30,40,50,60};
int i=2, j=3, ctr1, ctr2;
7
//display elements in row-wise
ctr1=0;
while(ctr1<i)
9.
10
11
12E
ctr2=0;
while(ctr2<j)
{
cout<<arr1[ctr1][ctr2]<<" ";
ctr2++;
}
cout<<endl;
13
14
15 E
16
17
18
19
20
ctr1++;
21
}
22
23
return 0;
24
25 L }
Transcribed Image Text:#include <iostream> using namespace std; 3 int main() 59 { 4 int arr1[2][3]={10,20,30,40,50,60}; int i=2, j=3, ctr1, ctr2; 7 //display elements in row-wise ctr1=0; while(ctr1<i) 9. 10 11 12E ctr2=0; while(ctr2<j) { cout<<arr1[ctr1][ctr2]<<" "; ctr2++; } cout<<endl; 13 14 15 E 16 17 18 19 20 ctr1++; 21 } 22 23 return 0; 24 25 L }
Expert Solution
steps

Step by step

Solved in 2 steps with 2 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