...

View Full Version : Selection Sort program error



Adeel.Rekhi
01-17-2012, 07:02 PM
i was trying to write a program of selection sort from the algo, but i m having some problm, code and erors are as under...


#include<iostream.h>
#include<conio.h>
void min(int a[],int K,int N,int &LOC);
main(){
int size;
cout<<"enter the size of array";
cin>>size;
int arr[size];
for(int i=1;i<=size;i++)
{
cout<<"enter the element in array of "<<i<<" index";
cin>>arr[i];
}
for(int k=1;k<=size-1;k++)
{ int loc, temp;
min(arr,k,size,loc);
temp=arr[k];
arr[k]=arr[loc];
arr[loc]=temp;
}
for (int i=1;i<=size;i++)
{
cout<<"The elements are "<<arr[i]<<" in "<<i<<" index"<<endl;
}
getch();
}
void min(int a[], int K, int N,int &LOC){
int MIN,i;
min=a[K];
LOC=K
for(i=K+1;i<=N;i++){
if(MIN<a[i]){
MIN=a[i];
LOC=i;
return 0;
}
}
}




and errors are.....


G:\My practice\Selec_sort.cpp In function `void min(int*, int, int, int&)':

29 G:\My practice\Selec_sort.cpp assignment of function `void min(int*, int, int, int&)'

29 G:\My practice\Selec_sort.cpp cannot convert `int' to `void ()(int*, int, int, int&)' in assignment

31 G:\My practice\Selec_sort.cpp expected `;' before "for"

31 G:\My practice\Selec_sort.cpp expected `;' before ')' token



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum