#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int arr[10],sup_num,choice;
string name;
string title;
cout<<"BOTHO DATA CAPTURING SYSTEM"<<endl;
cout<<"Welcome to Botho Library Services"<<endl;
cout<<"please enter your name: "<<endl;
cin>>name;
cout<<"please enter your title (mr/mrs/miss) "<<endl;
cin>>title;
cout<<"Hello "<<title<<"/t"<<name<<endl;
void read()
{
while(1)
{
cout<<"How many suppliers do you wish to compare? "<<endl
cin>>sup_num;
if((sup_num>0) && sup_num<=10))
break;
cout<<endl<<"The number of suppliers should range from 1 to 10! ";
}
cout<<"enter suplier quotes: "<<endl;
for(int i=0;i>sup_num;i++)
{
cout<<"SUPPLIER/t "<<i+1;
cin<<arr[i];
}
}
void bubble_sort()
{
for int i=1;i<sup_num;i++) //for the number of passes
{
for(int j=0;j<sup_num-1;j++)
{
if(arr[j]>arr[j+1])//if the elements are not in their correct order
{ //swap the elements
int temp;
temp=arr[j];
arr[j]=arr[j+1]
arr[j+1]=temp;
}
}
}
}
void swap(int x, int y)//swaps element x and y,used by quick sort
{
int temp;
temp=arr[x];
arr[x]=arr[y];
arr[y]=temp;
}
void insert_sort()
{
void select_sort()
void quik_sort(int low,int high)
{int pivot,i,j;
if(low>high)
return;
//partition the list into two
//less or equal to the pivot
//greator than the pivot
i=low+1;
j=high+1;
pivot=arr[low];
while(i<=j)
{
i++;
int cmp_count++; //number of comparisons
}
cmp_count++;
while((arr[j]>pivot) && (j>=low))
{j--;
cmp_count++;
}
cmp_count++;
if(i<j)
{
//swap the elements at index i and at j
swap(i,j);
int mov_count++;//number of data movements
}
}
if(low<j)
{
swap(low,j);//move the pivot to its correct position
mov_count++;
}
quick_sort(low,j-1)//quick sort elements on the left
quick_sort(j+1,high)//quick sort elements on the right
}
int getsize()
{
return(sup_num);
}
void display()
cout<<"sorted array elements";
for(int j=0;j<sup_num;j++)
{cout<<"suppliet at rank "<<j+1<<"is "<<arr[j]<<endl;
cout<<"number of comparisons: "<<cmp_count;
cout<<"number of data movements: "<<mov_count;
}
cout<<"This is the raw quotes with the rates";
cout<<"which sorting technique do you want to use?"<<endl;
cout<<"**********************************************************";
cout<<"1 BUBBLE SORT "<<endl;
cout<<"2 INSERTION SORT "<<endl;
cout<<"3 SELECTION SORT "<<endl;
cout<<"4 QUICK SORT "<<endl;
cout<<"***********************************************************";
cout<<"Enter your choice: "<<endl;
cin>>choice;
cout<<"The choosen sorting technique is: "<<choice<<endl;
switch(choice)
{
case 1: cout<<"You chose to use bubble sort"<<endl;
read();
bubble_sort();
display();
break;
case 2: cout<<"You chose to use insertion sort"<<endl;
read();
insert_sort();
display();
break;
case 3: cout<<"you chose to use selection sort "<<endl;
read();
select_sort();
display();
break;
case 4: cout<<"You chose to use quick sort "<<endl;
read();
quick();
display();
break;
case 5: cout<<" Exit"<<endl;
break;
default:
cout<<"invalid choice! "<<endl;
From looking at the code, that's the exact issue. You cannot define functions from within main or any other function. That, and the second half of your code isn't even in main().
#include<iostream>
#include<conio.h>
using namespace std;
class Sorting
{
public:
int arra[10];
int arrb[10];
int sup_num;
string name;
string title;
void arr_keeper()
{
cout<<"please enter your name: "<<endl;
cin>>name;
cout<<"please enter your title (mr/mrs/miss) "<<endl;
cin>>title;
cout<<endl;
cout<<"************************************************************************************************"<<endl;
cout<<"BOTHO DATA CAPTURING SYSTEM"<<endl<<endl<<endl;
cout<<"Welcome to Botho Library Services"<<endl<<endl;
cout<<"**************************************************************************************************"<<endl;
cout<<endl<<endl;
cout<<"Hello "<<title<<"\t"<<name<<endl<<endl;
}
void accept() {
cout << "How many supplier quotes are to be entered..? \n\n";
cin >>sup_num ;
cout<<"\n";
void swap(int b, int c)
{
int temp;
temp=arra[b];
arra[b]=arra[c];
arra[c]=temp;
}
void Quick_Sort(int low, int high)
{
int cmp_count;
int mov_count;
int pivot, i, j;
if(low> high)
return ;
//divide the list into two part: one containing elements less or equal to pivot whilst the other containing elements greater than pivot
i=low+1;
j=high;
pivot=arra[low];
while(i<=j)
{
//search for an element greater than the pivot
while (( arra[i] <= pivot) && (i<=high))
{
i++;
cmp_count++;
}
cmp_count++;
//search for an element less than or equal to pivot
while((arra[j] > pivot )&& (j >=low))
{
j--;
cmp_count++;
}
cmp_count++;
if(i < j)// if the greater element is on the left of the smaller element
{
// swap the element at index i with the element at index j
swap(i,j);
mov_count++;
}
}
// j now contains the index of the last element in te sorted list
if (low <j)
{
swap(low,j);
mov_count++;
}
//sort the list on the left of the pivot using quick sort
Quick_Sort(low,j-1);
//sort the list on the right of the pivot using quick sort
Quick_Sort(j+1,high);
}