C PROGRAM FOR ARRAY REVERSE
This code will insert an element into an array, For example consider an array a[10] having three elements in it initially and a[0] = 1, a[1] = 2 and a[2] = 3 and you want to insert a number 45 at location 1 i.e. a[0] = 45, so we have to move elements one step below so after insertion a[1] = 1 which was a[0] initially, and a[2] = 2 and a[3] = 3. Array insertion does not mean increasing its size i.e array will not be containing 11 elements.
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,n;
clrscr();
printf("Enter the n value");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("enter the a[%d]=",i);
scanf("%d",&a[i]);
}
for(i=n;i>0;i--)
{
printf("%d\n",a[i]);
}
getch();
}

0 comments:
Post a Comment