/**********************************************
Program to reverse the elements of an array
**********************************************/
#include<stdio.h> // include stdio.h library
#define MAX 5
int main(void)
{
int arr[MAX] = {10, 20, 30, 40, 50},
i, j, tmp;
i = 0;
j = MAX - 1; // assign the last valid index
while(i < j)
{
// swap the elements
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
// print the reversed array
for(int k = 0; k < MAX; k++)
{
printf("%d ", arr[k]);
}
return 0; // return 0 to operating system
}