Reverse Array
Coding Problem Keys
Reverse Array
Problem Statement
The Program must accept N integers as the input. The program must print all the N integers in reverse order as the output.
Boundary Condition(s)
1 <= N <= 100
1 <= Each integer value <=10^7
Input Format
The First line contains the value of N.
The Second line contains the N integers separated by space(s).
Output Format
The First line contains the N integers in reverse order separated by a space.
Example Input/Output 1
Input
5
2 4 7 9 10
Output
10 9 7 4 2
Explanation
The five integers are printed in reverse order.
Example Input/Output 2
Input
8
78 45 89 56 12 67 78 10
Output
10 78 67 12 56 89 45 78
Note: Max Execution Time Limit: 4000 millisecs
Solution
Programming Language: C Language
#include <stdio.h> #include <stdlib.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]); } }
//Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments