Answer to Question #269087 in C for Karthik

Question #269087

2. Mr. Raju want to read 10 array elements and wants to display them in the reverse way. Write a C








program to help Mr. Raju to display the array elements in the reverse way

1
Expert's answer
2021-11-21T04:51:32-0500


#include <stdio.h>


int main()
{
    printf("Enter the number of array elements: ");
    int n;
    scanf("%d",&n);
    int arr[n];
    
    printf("\nEnter elements of the array:\n");
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    //print original array
    printf("\nOriginal array:\n");
    for(int i=0;i<n;i++){
        printf("%d  ",arr[i]);
    }
    //print reversed array
    printf("\nReversed array:\n");
    for(int i=(n-1);i>=0;i--){
        printf("%d  ",arr[i]);
    }


    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