Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Use a copy function from exercise 2 to copy the third through fifth elements of a seven-element array into a three-element array.
- The function itself need not be altered; just choose the right actual arguments.
- (The actual arguments need not be an array name and array size. They only have to be the
- address of an array element and a number of elements to be processed.)
- */
- #include <stdio.h>
- #define SIZE 7
- void copy_arr(double source[], double target[], int element);
- int main(void)
- {
- double source[SIZE] = { 2.4, 5.6, 7.8, 4.7, 2.6, 8.4, 3.6 };
- double target[SIZE - 4];
- int i;
- for (i = 2; i < 5; ++i) {
- copy_arr(source, target, i);
- }
- return 0;
- }
- void copy_arr(double source[], double target[], int element)
- {
- int tar_element = element - 2;
- target[tar_element] = source[element];
- printf("%.1lf ", target[tar_element]);
- putchar('\n');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement