Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: What code will accomplish the task for CODE SEGMENT A? What code will

ID: 3580483 • Letter: Q

Question

Question:

What code will accomplish the task for CODE SEGMENT A?

What code will accomplish the task for CODE SEGMENT B?

What code will accomplish the task for CODE SEGMENT C?

What code will accomplish the task for CODE SEGMENT A?


What code will accomplish the task for CODE SEGMENT B?


What code will accomplish the task for CODE SEGMENT C?

Below is some code to create and print a 10X 10 matrix. The code is incomplete, you will have to complete the code to do the following Every cel in the 10X10 matrix should be set to 0 (zero), except for the edges. The edges should be set to 1 ou can think of a picture frame. Here is an example of what the outcome should look like, ie., what the code needs to do: 11 11 10 000 0000 10 000 0000 1 10 0000 0000 100 0000001 10 000 0000 1 10 000 0000 1 10 000 0000 1 100 0000001 11 Create10By 10 Defines the entry point for the console application. #include iostream using namespace std; This program will create a 10X10 matrix. All matrix cells' vill be 0, except the boarder int main (int argc, char argvO) const int SLZE 10. int matrox(SIZENSIZE: Populate the matrix for (int 0, i SIZE; i++X for (int j 0; j SIZE j 00 create top and bottom boarder CODE SEGMENT A create left and right boarder else CODE SEGMENT B otherwise else{ CODE SEGMENT C print out the matrix or (int cout matroclin court end. return

Explanation / Answer

CODE SEGMENT A

// create top and bottom boarder
//
if (i == 0 || i == 9){
matrix[i][j] = 1;
}
//

CODE SEGMENT B

// create left and right boarder
//
else if (j == 0 || j == 9){
matrix[i][j] = 1;
}
//

CODE SEGMENT C

// otherwise
//
else {   
matrix[i][j] = 0;
}

//

Final Complete Programme :

#include <iostream>

using namespace std;
//
// This program will create a 10 X 10 matrix.
// All matrix 'cells' will be 0, except for
// the boarder:
//
int main(int argc, char* argv[])
{
const int SIZE = 10;
int matrix[SIZE][SIZE];
//
// Populate the matrix
//
for (int i = 0; i < SIZE; i++){
for (int j = 0; j < SIZE; j++ ){
//
// create top and bottom boarder
//
if (i == 0 || i == 9){
matrix[i][j] = 1;
}
//
// create left and right boarder
//
else if (j == 0 || j == 9){
matrix[i][j] = 1;
}
//
// otherwise
//
else {   
matrix[i][j] = 0;
}
}
}
//
// print out the matrix
//
for (int i = 0; i < SIZE; i++){
for (int j = 0; j < SIZE; j++ ){
cout << matrix[i][j] << " ";
}
cout << endl;
}

return 0;
}

Output :

1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote