Reverse array in c

In this tutorial, we learn about reverse array in c, I think are you at the beginner level of programming that why you looking for reverse array in c and if you know array-like take array of elements from user and display the array elements using loops than good and if not then learn my tutorials on array or from elsewhere but learn basic of array and both things you can't do then no problem I will share problem in very clear way. so, you can understand each step easily. Now, I am not taking much of your time.


reverse array in c

Reverse array in c

In the future I will share reverse array in java, Incoming java program we use the same concept but you find a difference in syntax of the language. so, I hope you known this concept for future use.

Source Code:

#include<stdio.h>
int main()
{
 int n,c,d,a[10],b[10];

  printf("Enter the number of elements in array");

   scanf("%d",&n);

  printf("\nEnter array elements\n");
   for(c=0;c<n;c++)
   {
    scanf("%d",&a[c]);
   }
   for(c=n-1,d=0;c>=0;c--,d++)
   {
    b[d]=a[c];
   }
   for(c=0;c<n;c++)
   {
    a[c]=b[c];
   }
  printf("\nReverse array is \n");
   for(c=0;c<n;c++)
   {
    printf("%d\n",a[c]);
   }
 return 0;
}


Output:



Enter the number of elements in array: 8

Enter array elements
80
70
60
50
40
30
20
10

Reverse array is
10
20
30
40
50
60
70
80

--------------------------------

In the above article, We use loops to solve reverse array in c and if you know something new then please comment or send mail to featured and for contribution to codeamy.in and we also share reverse array java program soon.

Happy Coding!! 😊

Share this

0 Comment to "Reverse array in c"

Post a Comment