Please help me to solve the following program in C++ array. After compile message appears "Possible use of "i" before definition.
#include<iostream.h>
#include<conio.h>
void selsort(int [],int);
void main()
{
int AR[50],N,z;
clrscr();
cout<<"How many elements do U want to create array with?(max.50).....";
cin>>N;
cout<<"\n Enter Array elements.....\n";
for(int i=0;i<N;i++)
{
cin>>AR[i];
}
selsort(AR,N);
cout<<"\n\n The sorted array is as shown below.....\n";
for(int i=0;i<N;i++)
cout<<AR[i]<<" ";
cout<<endl;
cin>>z;
}
void selsort(int AR[],int size)
{
int small,pos,tmp,i;
for(int i=0;i<size;i++)
{
small=AR[i]; pos=i;
}
for(int j=(i+1);j<size;j++)
{
if(AR[j]<small)
{
small=AR[j];
pos=j;
}
}
tmp=AR[i];
AR[i]=AR[pos];
AR[pos]=tmp;
cout<<"\n Array after pass-"<<(i+1)<<"-is:\n";
for(int j=0;j<size;j++)
cout<<AR[j]<<" ";
}
Thank you in advance.