Answer to Question #231917 in C for Vishnukumar

Question #231917
An array is type of data structure that stores the elements in contiguous block of memory, create an array with name "list" and size of an array is N. your task is to print the array elements in an reverse order.

list=[1,2,3,4,5]

output 5,4,3,2,1

Note: use function concept to process the array elements and print it in the reverse order.

Reverse array has the following parameter

int list[n]

return int
1
Expert's answer
2021-09-01T23:57:42-0400


#include <stdio.h>


void reverseArray(){    
    int arr1[] = {11, 12, 13, 14, 15};     
    int len = sizeof(arr1)/sizeof(arr1[0]);    
        
    printf("Original: \n");    
    for (int i = 0; i < len; i++) {     
        printf("%d ", arr1[i]);     
    }      
    printf("\n");    
    printf("Reversed: \n");      
    for (int i = len-1; i >= 0; i--) {     
        printf("%d ", arr1[i]);     
    } 
}
int main()
{
    reverseArray();


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS