C++: I am trying to sort the given array in the main method but I am getting the following error: error: no match for ‘operator


C++: I am trying to sort the given array in the main method but I am getting the following error:


error: no match for ‘operator<’ (operand="" types="" are="" ‘std::basic_ostream’="" and="" ‘void’)="" cout="">< "\nsorted="" array:="" "="">< sortarray(arr,="">



Code:


void sortArray(int arr[], int length) {
    for (int i = 0; i < length;="" i++)="">
      for (int j = i + 1; j < length;="" j++)="">
        if (arr[j] < arr[i])="">
          // Swaps values
          int temp = arr[i];
          arr[i] = arr[j];
          arr[j] = temp;
        }
      }
    }
    cout <>
    for (int i = 0; i < length;="" i++)="">
      cout <>
      if (i < length="" -="">
        cout < ",="">
    }
    cout <>
} // Sort Array



int main() {


int arr[] = {3, 4, 1, 2};
int length = sizeof(arr) / sizeof(arr[0]);


cout < "\nsorted="" array:="" "="">< sortarray(arr,="">


}



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here