Previous Next
0 / 21
Module DEMO-32-106DEMO-C-32

Print Elements in Reverse Order

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a C program to print the elements of a 1D array in reverse order. Read n, then the elements, and finally display them from the last index down to 0.

Example

Input:

5 1 2 3 4 5

Output:

5 4 3 2 1

Constraints

1 <= n <= 100

Input Format

n followed by n integers

Output Format

Reversed array

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
5
1 2 3 4 5
5 4 3 2 1
Reversed sequence.
Sample #2
Public sample
1
99
99
Single element remains same.
Sample #3
Public sample
3
-1 0 1
1 0 -1
Negatives and zero.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings