C Programming Code Examples C > Arrays and Matrices Code Examples Program to reverse an array without using another array Program to reverse an array without using another array Logic to reverse array without using another array relies on the above logic. What we need to do is maintain two array indexes. First arrIndex that moves from size - 1 to 0. Second revIndex that moves from 0 to size - 1. Now instead of copying values to a reverse array, swap values of array at arrIndex and revIndex indexes. This will reverse the entire array. #include <stdio.h> #define maxsize 100 // Defines maximum size of array int main() { int array[maxsize]; int size, j, arrIndex, revIndex; int temp; // Used for swapping /* Input size of the array */ printf("Enter size of the array: "); scanf("%d", &size); /* Input array elements */ printf("Enter elements in array: "); for(j=0; j<size; j++) { scanf("%d", &array[j]); } revIndex = 0; arrIndex = size - 1; while(revIndex < arrIndex) { /* Copy value from original array to reverse array */ temp = array[revIndex]; array[revIndex] = array[arrIndex]; array[arrIndex] = temp; revIndex++; arrIndex--; } /* Print the reversed array */ printf("\nReversed array : "); for(j=0; j<size; j++) { printf("%d\t", array[j]); } return 0; }