Question: I have 3 function like this: bool equal(const int* first1, const int* last1, const int* first2, const int* last2); // Example, assuming `data1` and `data2`

I have 3 function like this:

bool equal(const int* first1, const int* last1, const int* first2, const int* last2); // Example, assuming `data1` and `data2` are int arrays // and we want to know if the first 5 elements compare equal: bool result = equal(data1, data1 + 5, data2, data2 + 5); 
void copy(const int* first, const int* last, int* d_first); // Example: // copy the first five elements from data1 to data2 copy(data1, data1 + 5, data2); 
void print(const int* first, const int* last); // Example: print(data, data + 5); // prints {0,1,2,3,4} " print(data + 1, data + 3); // prints {1,2} "

Write Main function with these requirement below:

- Generate a random number, n, in the range [10..100].

- Allocate two dynamic int arrays that can store n integers each.

int* arr1 = nullptr; arr1 = new int[n]; int* arr2 = new int[n];

- Copy the first 10 elements of data2 to the first 10 elements of data1, Compare the first ten elements of data1 and data2 for equality, and print out

NOTE: Do not use the [ ] operator to index elements of an array. Use pointers to move around arrays, and use indirection to get values.

I did error with main function, Anyone can help me write this Main function:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!