Code Check on hw_6.cpp

I have problems compiling this program this is my code can you please help me find the errors


#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>


void hitEnter();
void drawMenu();
void fillRandom();
void display( const int [] );
void bubbleSort( int[], int );
int linearSearch( const int [], int, int );
int binarySearch( const int [], int, int, int, int );

int main ()
{
       
    int arraySize[50] = 0;
    char choice;  
   
    bubbleSort(arraySize, 50);
   
    int entry = 0;
    int Sta;
    Sta = binarySearch(arraySize, 0, 50 - 1, entry);
   
   
    drawMenu();
    cin.get(choice);
   
    do {
       
        switch (choice) {
           
        case '1':   cout << "Array filled with the numbers between 1-30 " << endl;
            cin >> entry;
            fillRandom(arraySize, entry);
            display(arraySize, entry);
            break;
           
        case '2':   cout << "array displayed on screen" << endl;
            display (arraySize, entry);
            break;
           
        case '3':   cout << "Sort the array in descending order" << endl;
            bubbleSort(arraySize, entry);
            display(arraySize, entry);
            break;
           
           
        case '4':   cout << "search for an element in either the sorted or the unsorted array " << endl;
            cin >> entry;
            linearSearch(arraySize, 0,entry-1, entry);
          if(Sta == -1)
            cout << "Not found!!" << endl;
          else
            cout << " Number " << entry << " found array " << Sta << endl;
          
            display(arraySize, entry);
            break;            
           
        case '5':   cout << "search for an element in a sorted array " << endl;
            cin >> Num;
            binarySearch(arraySize, 0, entry-1, entry);
          if(Sta == -1)
            cout << "Not found" << endl;
          else
            cout << "Number " << entry << " found in array " << Sta << endl;
          
            display(arraySize, entry);
            break;
           
        case 'q':   cout <<  "\nExiting program goodbye.\n";
            break;
        default:    break;
           
        }  
        hitEnter();
        drawMenu();
        cin.get(choice);
       
    } while ( choice != 'q' );
   
    return 0;
   
} // end main

void drawMenu() {
   
    cout << "\033[2J";  
    cout << "\t\tHomework 6";
    cout << "\n\n\n[1]fillRandom\n[2]Display\n[3]Sort\n[4]Search\n[5]binarySearch\n[q]Quit\n\nEnter Choice: ";
   
}

void hitEnter(){
    char ch;
    do                        
    cin.get(ch);      
    while  ( ch == ' ');  
   
   
    cout << "\n\nHit Enter to continue....";
    cin.get(ch);        
}

void bubbleSort(arraySize, int counter){
   
    for(int i = 0; i < counter - 1; i++) {
      for(int j = 0; j < counter - 1; j++) {
           
            if(arraySize[j] < arraySize[j+1]) {
               
                int temp      = arraySize[j];
                arraySize[j]   = arraySize[j+1];
                arraySize[j+1] = temp;
 }
 }
 }
   
}

int binarySearch(arraySize, int low, int high, int size) {
   
    int high, low, middle, searchKey;
   
    while (low <= high) {
       
        middle = (low + high) / 2;
       searchKey = arraySize[middle] - size;
       
        if (searchKey == 0)        
      
                 return middle;
        else if (searchKey < 0)
      
            low = middle + 1;
        else
            high = middle - 1;
    }
   
    return -1;  
   
}


void fillRandom(arraySize, int Counter) {
   
    int c;
   
    srand((unsigned) time(NULL));
   
    arraySize[0] = rand() % 30;
    for (c = 0; c < Counter; c++)
        arraySize[c] = rand() % Counter;
    return;
   
}

void display(arraySize, int Counter) {
   
    int c;
   
    for (c = 0; c < Counter; c++) {
       
        cout << setw(5) << arraySize[c];
        if (c % 10 == 9)
            cout << endl;
       
    }
   
    cout << endl;
    return;
   
}

int linearSearch(arraySize[], int low, int high, int size) {
   
    int i=0;
    int b=0;
    int a, high;
   
    while((a <= high) && (b==0)){
       
        if (size == arraySize[i])
           b=1;
        else
            i++;
    }
   
    if(b==1)
        a = i;
    else
        a = -1;
   
    return a;
   
}

Yesenia1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
To be honest - the above is a mess. The following should compile:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

void hitEnter();
void drawMenu();
void fillRandom(int array[], int Counter);
void display( const int [], int count );
void bubbleSort( int[], int );
int linearSearch(int arraySize[], int low, int high, int size);
int binarySearch( const int [], int, int, int);

int main ()
{
       
   int arraySize[50];
   char choice;  
   
    bubbleSort(arraySize, 50);
   
   int entry = 0;
   int Sta;
   Sta = binarySearch(arraySize, 0, 50 - 1, entry);
   
   
   drawMenu();
   cin.get(choice);
   
   do {
       
       switch (choice) {
           
       case '1':   cout << "Array filled with the numbers between 1-30 " << endl;
            cin >> entry;
           fillRandom(arraySize, entry);
           display(arraySize, entry);
           break;
           
       case '2':   cout << "array displayed on screen" << endl;
            display (arraySize, entry);
           break;
           
       case '3':   cout << "Sort the array in descending order" << endl;
            bubbleSort(arraySize, entry);
           display(arraySize, entry);
           break;
           
           
       case '4':   cout << "search for an element in either the sorted or the unsorted array " << endl;
           cin >> entry;
           linearSearch(arraySize, 0,entry-1, entry);
        if(Sta == -1)
          cout << "Not found!!" << endl;
        else
          cout << " Number " << entry << " found array " << Sta << endl;
       
            display(arraySize, entry);
           break;            
           
       case '5':   cout << "search for an element in a sorted array " << endl;
           binarySearch(arraySize, 0, entry-1, entry);
        if(Sta == -1)
          cout << "Not found" << endl;
        else
          cout << "Number " << entry << " found in array " << Sta << endl;
       
            display(arraySize, entry);
           break;
           
       case 'q':   cout <<  "\nExiting program goodbye.\n";
           break;
       default:    break;
           
        }  
        hitEnter();
       drawMenu();
       cin.get(choice);
       
   } while ( choice != 'q' );
   
   return 0;
   
} // end main

void drawMenu() {
   
   cout << "\033[2J";  
    cout << "\t\tHomework 6";
   cout << "\n\n\n[1]fillRandom\n[2]Display\n[3]Sort\n[4]Search\n[5]binarySearch\n[q]Quit\n\nEnter Choice: ";
   
}

void hitEnter(){
   char ch;
   do                        
   cin.get(ch);      
   while  ( ch == ' ');  
   
   
   cout << "\n\nHit Enter to continue....";
   cin.get(ch);        
}

void bubbleSort(int arraySize[], int counter){
   
   for(int i = 0; i < counter - 1; i++) {
     for(int j = 0; j < counter - 1; j++) {
           
           if(arraySize[j] < arraySize[j+1]) {
               
               int temp      = arraySize[j];
               arraySize[j]   = arraySize[j+1];
               arraySize[j+1] = temp;
}
}
}
   
}

int binarySearch(const int arraySize[], int low, int high, int size) {
   
   int middle, searchKey;
   
   while (low <= high) {
       
       middle = (low + high) / 2;
      searchKey = arraySize[middle] - size;
       
       if (searchKey == 0)        
     
               return middle;
       else if (searchKey < 0)
   
            low = middle + 1;
       else
           high = middle - 1;
   }
   
   return -1;  
   
}


void fillRandom(int arraySize[], int Counter) {
   
   int c;
   
   srand((unsigned) time(NULL));
   
    arraySize[0] = rand() % 30;
    for (c = 0; c < Counter; c++)
       arraySize[c] = rand() % Counter;
   return;
   
}

void display(const int arraySize[], int Counter) {
   
   int c;
   
   for (c = 0; c < Counter; c++) {
       
       cout << setw(5) << arraySize[c];
       if (c % 10 == 9)
           cout << endl;
       
   }
   
   cout << endl;
   return;
   
}

int linearSearch(int arraySize[], int low, int high, int size) {
   
   int i=0;
   int b=0;
    int a;
   
   while((a <= high) && (b==0)){
       
       if (size == arraySize[i])
          b=1;
       else
            i++;
   }
   
   if(b==1)
       a = i;
   else
       a = -1;
   
   return a;
   
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
markdocCommented:
hey, at first glance, one source of your errors would be a missing line after the #include lines:

using namespace std;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.