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

Write C++ statements that do the following: Declare an array alpha of 10 rows an

ID: 3683804 • Letter: W

Question

Write C++ statements that do the following: Declare an array alpha of 10 rows and 20 columns ot type int. Initialize the array alpha to 0. Store 1 in the first row and 2 in the remaining rows. Store 5 in the first column, and make sure that the value in each subsequent column is twice the value in the previous column. Suppose that you have the following declarations: int times[30][7]; int speed[15][7]; int trees[100][7]; int students[50][7]; Write the definition of the function print that can be used to output the contents of these arrays. Write die C++ statements that calls the function print to output the contents of the arrays times, speed, trees, and students.

Explanation / Answer

int alpha[10][20];

for(int i=0;i<10;i++)
for(int j=0;j<20;j++)
alpha[i][j] = 0;

for(int i=0;i<10;i++)
for(int j=0;j<20;j++)
if(i==0)
alpha[i][j] = 1;
else
alpha[i][j] = 2;

int s = 5;
for(int i=0;i<20;i++)
{
for(int j=0;j<10;j++)
alpha[j][i] = s;

s = s*2;
}


5
void print(int a[][7], int r)
{
for(int i=0;i<r;i++)
{
for(int j=0;j<7;j++)
print("%d ",a[i][j]);

printf(" ");
}
}

print(times, 30);
print(speed, 15);
print(trees, 100);
print(student, 50);

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