Would someone be so kind as to help me with this problem, thank you. //Introduct
ID: 3816045 • Letter: W
Question
Would someone be so kind as to help me with this problem, thank you.
//Introductory22Project.cpp - displays the contents of a
//two-dimensional array, column by column and row by row
//Created/revised by <your name> on <current date>
#include <iostream>
using namespace std;
int main()
{
int nums[2][4] = {{17, 24, 86, 35},
{23, 36, 10, 12}};
//display column by column
cout << endl;
//display row by row
return 0;
} //end of main function
22. Follow the instructions for starting C++ and viewing the Introductory22.cpp file, which is contained in either the Cpp8Chap12Introductory22 Project folder or the Cpp8 Chap12 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) The program should display the contents of the two-dimensional array, column by column and also row by row. Complete the program using a while statement in the outer loops and a for statement in the nested loops. Save and then run the program.Explanation / Answer
Hi, I have added the code below. I have used both nested loop and for loop inside while loop for column by column and row by row respectively. Hope this is what you wanted
//Introductory22Project.cpp - displays the contents of a
//two-dimensional array, column by column and row by row
//Created/revised by <your name> on <current date>
#include <iostream>
using namespace std;
int main()
{
int nums[2][4] = {{17, 24, 86, 35},
{23, 36, 10, 12}};
//display column by column
cout <<"Column By Column" <<endl;
for(int i = 0; i<4;i++) {
for(int j = 0;j<2;j++) {
cout<<nums[j][i]<<" ";
}
}
cout<<endl;
//cout << <<endl;
//display row by row
cout <<"Row By Row" <<endl;
int k = 0;
while(k < 2) {
for(int l = 0;l<4;l++) {
cout<<nums[k][l]<<" ";
}
k++;
}
cout<<endl;
return 0;
} //end of main function
Output: -
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.