[pfemidi@pfemidi ~]$ cat foobar.c
#include <stdio.h>
int main () {
int arr1[8] = {1, 2, 3, 4, 5, 6, 7, 8};
int arr2[sizeof(arr1) / sizeof(arr1[0])];
for (size_t i = 0; i < sizeof(arr1) / sizeof(arr1[0]); i += 2)
printf("%d %d ", arr1[i], arr1[i + 1]);
printf("\n");
for (size_t i = 0, j = sizeof(arr1) / sizeof(arr1[0]) - 1; i < sizeof(arr1) / sizeof(arr1[0]); i += 2, j -= 2) {
arr2[i] = arr1[j - 1];
arr2[i + 1] = arr1[j];
}
for (size_t i = 0; i < sizeof(arr2) / sizeof(arr2[0]); i += 2)
printf("%d %d ", arr2[i], arr2[i + 1]);
printf("\n");
return 0;
}
[pfemidi@pfemidi ~]$ gcc foobar.c -o foobar
[pfemidi@pfemidi ~]$ ./foobar
1 2 3 4 5 6 7 8
7 8 5 6 3 4 1 2
[pfemidi@pfemidi ~]$