I am new to C++ language and I have no idea of pointers and their usage. I\'m facing the error \"[Error] invalid conversion from \'int\' to \'int*\' [-fpermissive]\"
Change the function call
cout << midd(ax, asize) << endl;
and declaration
double midd(int arr[], int size) { ... }
or go the C++ way: std::vector
or std::array
. For example
#include
#include
using namespace std;
double midd(array a) {
int mid = a.size() / 2;
return (a[mid] + a[mid + 1]) / 2.0;
}
int main() {
array ax = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
cout << midd(ax) << endl;
}