Implement a range function for a dynamic array which returns a new dynamic array that is a subset of the original. input parameters: array - (the array and any related parameters) start - index of the first element end - index of the last element Interval - An integer number specifying the incrementation of index This function returns a new dynamic array containing the elements from the start thru the end indices of the original array. All array indexing must be done using pointer arithmetic. For example, given the array: 49 96 99 47 76 29 22 16 30 22 If the start and end positions were 5 and 9 with step 2, return a new dynamic array: 29 16 22 Please use following main to test your function. int main(){ int *p = new int[10]{49,96,99,47,76,29,22,16,30,22}; int *q = range(p,10,5,9,2); for(int i=0;i<3;i++) cout<

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Implement a range function for a dynamic array which returns a new dynamic array that is a subset of the original.

input parameters: array - (the array and any related parameters) start - index of the first element
end - index of the last element
Interval - An integer number specifying the incrementation of index

This function returns a new dynamic array containing the elements from the start thru the end indices of the original array.
All array indexing must be done using pointer arithmetic.

For example, given the array: 49 96 99 47 76 29 22 16 30 22

If the start and end positions were 5 and 9 with step 2, return a new dynamic array: 29 16 22

Please use following main to test your function.

int main(){
int *p = new int[10]{49,96,99,47,76,29,22,16,30,22}; int *q = range(p,10,5,9,2);
for(int i=0;i<3;i++)

cout<<q[i]<<" "; // print 29 16 22 cout<<endl;
delete [] q;
q = range(p,10,1,8,3);

for(int i=0;i<3;i++)
cout<<q[i]<<" "; // print 96 76 16

cout<<endl;

delete [] q; }

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY