Function printArrayElementsInReverse

 Problem Coding Keys 

 Function printArrayElementsInReverse 

 Problem Statement 

You must implement the function printArrayElementsInReverse which accepts an integer array arr and it's size as the input. The function must print all the integers of the array in reverse order as the output.

 Example Input/Output 1 

 Input 

5
12 45 78 65 32

 Output 

32 65 78 45 12

 Explanation 

All five integers are printed in reverse order.

 Example Input/Output 2 

 Input 

4
10 80 20 60

 Output 

60 20 80 10

 Note: Max Execution Time Limit: 4000 millisecs 

 Solution: 

 Programming Language: C Language 

#include <stdio.h>
#include <stdlib.h>
void printArrayElementsInReverse(int arr[],int N){
    while(N>0){
        printf("%d ",arr[--N]);
    }
}
//Published By PKJCODERS
int main(){
    int N;
    scanf("%d",&N);
    int arr[N];
    for(int index = 0; index < N; index++){
        scanf("%d",&arr[index]);
    }
    
    printArrayElementsInReverse(arr, N);
    
    return 0;
}

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Array Elements - Divisible by D

Move Hundreds to End

Sort Number By Unit and Tenth Digits

Unique Characters

Print Alphabets

Print Matrix - Diagonal Zig Zag