Write a declaration statement for a 1D array called timedata

Write a declaration statement for a 1-D array called timedata with a length of n, where n is a pre-declared integer variable. (In other words, n has already been declared in advance.) (Remember, you cannot initialize variable-length arrays in a declaration statement) Write a declaration statement for a 2-D array called wavedata with a width of 2 and a length of 10.

Solution

Following Code:

1. Decleration statement for 1D-Array called timedata
   in Java ::: int timedata[] = new int[n];
   in C :: int *timedata = (int *) malloc (n*sizeof(int));

2. Decleration statement for 2D-Array called wavedata
   in Java ::: int wavedata[][] = new int[2][10];
   in C++ :: int **wavedata = new int*[2];
   for(int i=0;i<2;++i)
     wavedata[i] = new int[10];

I hope it clarifies, let me know if it requires anything more.

 Write a declaration statement for a 1-D array called timedata with a length of n, where n is a pre-declared integer variable. (In other words, n has already be

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site