Here we are going to reverse the elements of an array using C program.

Reverse the Elements of an Array :

ArrayRverse.c
#include<stdio.h>
int main(void)
{
    int i,j,temp;
    int arr[10] = {1,2,3,4,5,6,7,8,9,10};

    // Reversing the elements using temp variable.
    for(i=0,j=9; i<j; i++,j--){
        temp=arr[i];
        arr[i]=arr[j];
        arr[j]=temp;
    }

    printf("After reversing, the array is : ");
    for(i=0; i<10; i++){
        printf("%d  ",arr[i]);
    }

    printf("\n");
    return 0;
}

Output:

Terminal
After reversing, the array is: 10  9  8  7  6  5  4  3  2  1

Happy Learning 🙂

About the Author:

Avatar
Founder of onlinetutorialspoint.com Love Java, Python, Shell and opensource frameworks. Follow him on twitter and facebook for latest updates.

One Comment

  1. Milana Travis October 25, 2017 at 2:19 pm - Reply

    Thank you very much for your blog.

    I enjoyed reading this article.

Leave A Comment