Input Format
The first line contains an integer, , denoting the size of the array. The next line contains  space-separated integers denoting the elements of the array.
Constraints

, where  is the  element of the array.
Output Format
The output is handled by the code given in the editor, which would print the array.

hackerrank array reversal problem solution in c programming

Array Reversal problem solution in c programming | HackerRank

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num, *arr, i;
    scanf("%d", &num);
    arr = (int*) malloc(num * sizeof(int));
    for(i = 0; i < num; i++) {
        scanf("%d", arr + i);
    }
    /* Write the logic to reverse the array. */ 
    int* left_ptr = arr;
    int* right_ptr;
    int temp;
    for(i = 0; i < num; i++) {
        if(i == num - 1) {
            right_ptr = (arr + i);
        }
    }
    while(left_ptr < right_ptr) {
        temp = *right_ptr;
        *right_ptr = *left_ptr;
        *left_ptr = temp;
        right_ptr--;
        left_ptr++;
    }
      
    for(i = 0; i < num; i++) {
        printf("%d ", *(arr + i));
    }
    free(arr);
    return 0;
}