Write a function that will copy an arbitrary range of one array of integers into
ID: 3738360 • Letter: W
Question
Write a function that will copy an arbitrary range of one array of integers into another array. Your procedure will 1. The source array of integers 2: The length of the source array 3. A starting point in the source array 4. An ending point in the source array 5. The destination array of integers - the array that you will be copying numbers to 6. The length of the destination array 7. An integer indicating the index in the destination array where copying should start To avoid overflow, your routine should copy only those values that are available in the source array, to positions that are available in the destination array. If there are not enough values from the source array in the given range, use only those values that are available. If there is not enough space in the destination array, copy values only until the available space is full. Your function should return the number of values copiedExplanation / Answer
Please find my implementation of required function.
Please rate my answer if it helped you!!
void copyArray(int arr[], int n, int s, int e, int copy[], int n1, int s1) {
int j = s1;
for(int i=s; i<n && i<=e && j<n1 ; i++) {
copy[j] = arr[i];
j++;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.