Saturday, May 21, 2011

C program To reverse the contents of an Array

int main()
{
int a[100],i,j,k,b,t;


printf("\nEnter the size of 1 dimensional array");
scanf("%d",&b);
printf("\nEnter the array");
for(i=0;i scanf("%d",&a[i]);
for(j=0;j<=b/2;j++)
{
t=a[j];
a[j]=a[b-j-1];
a[b-j-1]=t;
}

for(k=0;kprintf("\n%d",a[k]);
system("pause");
return 0;
}

No comments:

Post a Comment

Google+ Followers