Arrays
Reverse an Array
Print array elements in reverse order.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Print array elements in reverse order.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
for (int i = n - 1; i >= 0; i--)
printf("%d ", arr[i]);
printf("\n");
return 0;
}
5
1 2 3 4 5
5 4 3 2 1