C++ program wont compile with expected expression and function not allowed here -


#include <iostream> using namespace std;   const int lab8 = 10; int labarray[lab8]; void promptuser(int [], int); void sortarray(int [], int); void showarray(const int[], int); int searcharray(const int [], int, int value); int x = 0; int results = 0;  int main() {  promptuser(labarray, lab8); sortarray(labarray, lab8); showarray(labarray, lab8); cout << "choose integer want search array: " << endl; cin >> x; results = searcharray(labarray, lab8, x); if (results == -1) {     cout << "that number not exist in array. \n";     else     {         cout << "the integer searched @ element " <<  results;         cout << " in array. \n";     }   }   void promptuser(int numbers[], int size) { int index; (index = 0; index <= size - 1;index++ ) {     cout << "please enter ten numbers fill array " << endl          << (index + 1) << ": ";     cin >> numbers[index]; }  } void sortarray(int array[], int size) { bool swap; int temp;  {     swap = false;     (int count = 0; count < (size -1); count++)     {         if (array[count] > array[count + 1])         {             temp = array[count];             array[count] = array[count + 1];             array[count + 1] = temp;             swap = true;         }     } } while (swap); } void showarray(const int array[], int size) { (int count = 0; count < size; count++) {     cout << "the array entered when sorted was: ";     cout << array[count] << " ";     cout << endl; } }  int searcharray(const int array[], int size, int value) { int first = 0, last = size - 1, middle, position = - 1; bool found = false;  while (!found && first <= last) {     middle = (first + last) / 2;     if (array[middle] == value)     {         found = true;         position = middle;     }     else if (array[middle] > value)         last = middle - 1;     else         first = middle + 1; }  return position; } 

i new c++ , working on assignment class. thought program wrote have worked life of me can not figure out why not compile. sure missing or not understanding how should work completely. errors keep receiving expected expression on line 26 'else' statement , when put 'if' , 'else' statements in started receiving function not allowed here errors. appreciated.

in if statement, open bracket { never close it. not sure if problem should raise issues.

    if (results == -1) {     cout << "that number not exist in array. \n";      **}**     else     {         cout << "the integer searched @ element " <<  results;         cout << " in array. \n";     } 

this how should look. try it


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -