#include<iostream.h>
#include<conio.h>
void swap(int a[],int n);
void main()
{
clrscr();
int a[10],i,n;
cout<<"\n\n";
cout<<"enter size";
cout<<"\n\n";
cin>>n;
cout<<"\n\n";
cout<<"enter elements";
cout<<"\n";
for(i=0;i<n;i++)
{
cout<<"\n";
cin>>a[i];
}
swap(a,n);
getch();
}
void swap(int a[],int n)
{
int i,temp;
for(i=0;i<n/2;i++)
{
temp=a[i];
a[i]=a[n/2+i];
a[n/2+i]=temp;
}
cout<<"\n\n";
cout<<"rearranged array is";
cout<<"\n\n";
for(i=0;i<n;i++)
{
cout<<a[i]<<"\t";
}
}
#include<conio.h>
void swap(int a[],int n);
void main()
{
clrscr();
int a[10],i,n;
cout<<"\n\n";
cout<<"enter size";
cout<<"\n\n";
cin>>n;
cout<<"\n\n";
cout<<"enter elements";
cout<<"\n";
for(i=0;i<n;i++)
{
cout<<"\n";
cin>>a[i];
}
swap(a,n);
getch();
}
void swap(int a[],int n)
{
int i,temp;
for(i=0;i<n/2;i++)
{
temp=a[i];
a[i]=a[n/2+i];
a[n/2+i]=temp;
}
cout<<"\n\n";
cout<<"rearranged array is";
cout<<"\n\n";
for(i=0;i<n;i++)
{
cout<<a[i]<<"\t";
}
}