Write a function to display only the second row of the follo

Write a function to display only the second row of the following double array int count [] [3] = {1, 2, 7, 8, 11, 16, 18, 12, 20, 25, 30, 40};

Solution

Here is the code for printing the second row of the double array

#include <iostream>
using namespace std;

void displaySecondRow(int count[][3]);
int main() {
   int count[][3] = {1,2,7,8,11,16,18,12,20,25,30,40};
   displaySecondRow(count);
   return 0;
}
void displaySecondRow(int count[][3]){
int i = 0;
for(i = 0;i<=2;i++){
cout<<count[1][i]<<\" \";
}
}

In the above array given , 3 represents the number of columns in the double array, and since we have to print the second row of the array, thus count[1] will point to the starting element (i.e., 8 in this case) of the second row.

Thus, count[1][0],count[1][1],count[1],[2] represent the elements of the 2nd row of the double array count.

 Write a function to display only the second row of the following double array int count [] [3] = {1, 2, 7, 8, 11, 16, 18, 12, 20, 25, 30, 40};SolutionHere is t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site