The goal of this code is to find the inner product of two arrays and then to take the first array and "reverse" the elements of the values in the array. I've figured out the inner product part, but for some reason my reverse function isn't working right. It reverses the first two but then doesn't work for the remaining values. Any help would be appreciated. Thank you ahead of time.
Code:
#include <stdio.h>
int inner_product(int a[], int b[], int count);
int reverse(int a[], int count);
int main(void)
{
int a[4] = {1, 4, 3, 5};
int b[4] = {2, -1, 1, 4};
int count = 0;
inner_product(a, b, count);
reverse(a, count);
return 0;
}
int inner_product(int a[4], int b[4], int count){
int total = 0;
for(count = 0; count < 4; count++){
total = (a[count] * b[count]) + total;}
printf("%d\n", total);
return 0;}
int reverse(int a[4], int count){
printf("%d ", a[0]);
printf("%d ", a[1]);
printf("%d ", a[2]);
printf("%d\n", a[3]);
int x = 3;
for(count = 0; count < 4; count++){
a[count] = a[x];
x = x - 1;}
printf("%d ", a[0]);
printf("%d ", a[1]);
printf("%d ", a[2]);
printf("%d\n", a[3]);
return 0;}