Reverse an Array Elements Program in C

Advertisements

Prev Tutorial Next Tutorial

Reverse an Array Elements Program in C

Reverse an Array Elements in C

#include<stdio.h>
#include<conio.h>

 void main()
  {
   int a[20],b[20],i,j,n;
   clrscr();
   printf("How many elements you want to enter: ");
   scanf("%d",&n);
   printf("Enter any %d elements in Array: ",n);
   for(i=0; i<n ;i++)
   {
   scanf("%d",&a[i]);
   }
   printf("Reverse of Array: ");

   for(i=n-1,j=0; i>=0;i--,j++)
   {
    b[i]=a[j];
   }
   for(i=0; i<n ;i++)
   {
   printf("%d ",b[i]);
   }
  getch();
  }

Output

How many elements you want to enter: 5
Enter any 5 elements in Array: 
1 4 2 7 5
Reverse of Array: 5 7 2 4 1

Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements