The following program gets the input and reverses it but it seems to skip the last element of the array while doing so
/*C program that declares an array A and inputs n integer values in A.
Then the contents of array A is copied to another array B in reversed order.
Finally print the elements of array B*/
#include<stdio.h>
int main()
{
int n, reverse, i ;
int A[100], B[100] ;
printf("Input the size of array A: ") ;
scanf("%d", &n ) ;
printf("Input the values of A: ") ;
for( i = 0 ; i<n ; i++ )
scanf("%d ", &A[i] ) ;
for(i = n-1 , reverse = 0 ; i>= 0 ; i--, reverse++)
B[reverse] = A[i] ;
for(i = 0 ; i<n ; i++ )
A[i] = B[i];
printf("Array B: ") ;
for(i=0 ; i<n ; i++ )
printf("%d ", A[i] ) ;
return 0 ;
}
Here is an online repel of the code demonstrating the problem