Question

In: Computer Science

Write a function that dynamically allocates references to other arrays. The goal is to end up...

Write a function that dynamically allocates references to other arrays. The goal is to end up with a square 2D array who's value increment with each index increment so that the values placed in first array start at zero and end at 9, and the values placed in the last array start at 90 and end at 99.

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

code.cpp

#include <iostream>
using namespace std;

int main()
{
   int **arrays;
   arrays = new int*[10];
   for(int i=0;i<10;i++){
       arrays[i] = new int[10];
   }

   int counter=0;
   for(int i=0;i<10;i++){
       for(int j=0;j<10;j++){
           arrays[i][j] = counter;
           counter++;
       }
   }


   cout<<"Content of the array is "<<endl;
   for(int i=0;i<10;i++){
       for(int j=0;j<10;j++){
           cout<<arrays[i][j]<<" ";
       }
       cout<<endl;
   }


   return 0;
}

output


Related Solutions

In C++ Write a program that dynamically allocates a built-in array large enough to hold a...
In C++ Write a program that dynamically allocates a built-in array large enough to hold a user-defined number of test scores. (Ask the user how many grades will be entered and use a dynamic array to store the numbers.) Once all the scores are entered, the array should be passed to a function that calculates the average score. The program should display the scores and average. Use pointer notation rather than array notation whenever possible. (Input Validation: Do not accept...
Write a program that dynamically allocates a built-in array large enough to hold a user-defined number...
Write a program that dynamically allocates a built-in array large enough to hold a user-defined number of test scores. (Ask the user how many grades will be entered and use a dynamic array to store the numbers.) Once all the scores are entered, the array should be passed to a function that calculates the average score. The program should display the scores and average. Use pointer notation rather than array notation whenever possible. (Input Validation: Do not accept negative numbers...
In C++ 1. Test Scores #1 Write a program that dynamically allocates a built-in array large...
In C++ 1. Test Scores #1 Write a program that dynamically allocates a built-in array large enough to hold a user-defined number of test scores. (Ask the user how many grades will be entered and use a dynamic array to store the numbers.) Once all the scores are entered, the array should be passed to a function that calculates the average score. The program should display the scores and average. Use pointer notation rather than array notation whenever possible. (Input...
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function...
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function must not be void and must output type int* i.e. it must take the form: int* merge_sort(int a[], int n) where a[ ] is the input matrix and n is the size of the matrix. You may use an auxiliary functions such as "merge." The returned array should be sorted using merge_sort and should not modify the array that was input (a[ ] ).
In C++ write a function to find a product of two matrices using arrays. The function...
In C++ write a function to find a product of two matrices using arrays. The function should be general and should accept any size matrices.
CONSUMER LAW ( please write the references of detail at the end ) TOPIC - CONSUMER...
CONSUMER LAW ( please write the references of detail at the end ) TOPIC - CONSUMER GUARANTEES – Schedule 2 of the Competition and Consumer Act 2010 (Cth) (“the ACL”) Provide the relevant sections of the ACL and give case examples (where applicable) to support your answers.
CONSUMER LAW ( please write the references of detail at the end ) CONSUMER GUARANTEES –...
CONSUMER LAW ( please write the references of detail at the end ) CONSUMER GUARANTEES – Schedule 2 of the Competition and Consumer Act 2010 (Cth) (“the ACL”) Explain the rule that goods must be reasonably fit for any disclosed purpose. Can the consumer guarantees be excluded under the ACL?
The goal of this project is to practice (Write a C Program) with a function that...
The goal of this project is to practice (Write a C Program) with a function that one of its parameter is a function.The prototype of this function is: void func ( float (*f)(float*, int), float* a, int length); This means the function: func has three parameters: float (*f)(float*, int): This parameter itself is a function: f that has two parameters and returns a floating-point number. In the body of the function: func we call the function: f with its arguments...
In C++, write a function that takes in as inputs two arrays, foo and bar, and...
In C++, write a function that takes in as inputs two arrays, foo and bar, and their respective array sizes. The function should then output the concatenation of the two arrays as a singly linked list. You may assume that you are provided a singly linked list header file.
Write a program of Binary Search in C++ by using function and arrays with the explanation.
Write a program of Binary Search in C++ by using function and arrays with the explanation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT