Answer to Question #301313 in C++ for adi

Question #301313

Define and initialize five arrays of integer types each having 6 elements and an array of pointers p of size 5. Store the starting address of each array to an array of pointers p. Design and call the function and initialize the values of these five arrays randomly using for loop and p inside this function. we can consider p as a 2D matrix. However, in that case, our number of rows (Which were 5 as there were 5 arrays stored in p) and the number of columns (which were 6 as each array had 6 elements) were fixed. In this question, your goal is to sort all data in the 2d array.


1
Expert's answer
2022-02-23T00:10:35-0500
#include <stdio.h>
#include <stdlib.h>

int a[6], b[6], c[6], d[6], e[0];
int *p[5];

int main() {
  p[0] = a;
  p[1] = b;
  p[2] = c;
  p[3] = d;
  p[4] = e;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 6; j++) {
      p[i][j] = rand();
    }
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog