Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions