Question: Could some one explain why my code gives me this error main.cpp: In function int main(int, char**): main.cpp:32:30: error: cannot convert double to double* for

Could some one explain why my code gives me this error

main.cpp: In function int main(int, char**): main.cpp:32:30: error: cannot convert double to double* for argument 1 to void readArray(double*, int) readArray(myArray[size], size); ^ main.cpp:33:31: error: cannot convert double to double* for argument 1 to void printArray(double*, int) printArray(myArray[size], size); ^

Code snippet

#include
#include
using namespace std;
/*
*
*/
double min(double myArray[], int size);
double max(double myArray[], int size);
double mean(double myArray[], int size);
double median(double myArray[], int size);
void sort(double myArray[], int size);
void readArray(double myArray[], int size);
void printArray(double myArray[], int size);
int main(int argc, char** argv)
{
int size;
double myArray[size];
readArray(myArray[size], size);
printArray(myArray[size], size);
//sort();
//min();
//max();
//mean();
//median();
return 0;
}
// This functions purpose is to find the min of the array
double min(double myArray[], int size){
double min = myArray[0];
nclude
#include
using namespace std;
/*
*
*/
double min(double myArray[], int size);
double max(double myArray[], int size);
double mean(double myArray[], int size);
double median(double myArray[], int size);
void sort(double myArray[], int size);
void readArray(double myArray[], int size);
void printArray(double myArray[], int size);
int main(int argc, char** argv)
{
int size;
double myArray[size];
readArray(myArray[size], size);
printArray(myArray[size], size);
//sort();
//min();
//max();
//mean();
//median();
return 0;
}
// This functions purpose is to find the min of the array
double min(double myArray[], int size){
double min = myArray[0];
for (int i = 0; i
if (myArray[i] < min)
min = myArray[i];
}
cout << "The min of the array is:"<< min <
}
//The purpose of the function is to find the max of the array by going through and searching through each index
//and comparing them to the previous index and if it's greater it sets it as the max value.
double max(double myArray[], int size){
double max = myArray[0];
for (int i = 0; i
`for (int i = 0; i
if (myArray[i] < min)
min = myArray[i];
}
cout << "The min of the array is:"<< min <
}
//The purpose of the function is to find the max of the array by going through and searching through each index
//and comparing them to the previous index and if it's greater it sets it as the max value.
double max(double myArray[], int size){
double max = myArray[0];
for (int i = 0; i
if (myArray[i] > max)
max = myArray[i];
cout << "The max of the array is:"<< max <
}
}
//The purpose of the function is to find the mean of the array by adding each index and dividing by the arrays size
double mean(double myArray[], int size){
double sum = 0;
for (int i = 0; i
sum = sum + myArray[i];
}
cout << "The mean of the array is:"<< mean <
}
//The purpose of the function is to find the median of the array
//It first checks to see if the size is even if so it then grabs the middle 2 values and adds them and divides it by 2
//If the size is odd the it simply divides it by 2 and looks at the index that equals
double median(double myArray[], int size){
double sum = 0;
double median;
if ( size% 2 == 0){
int i = size/2-1;
int j = size/2;
median = (myArray[i] + myArray[j])/2;
}
else {
median = myArray[size/2];
}
cout << "The median of the array is:"<< median <
}
void sort(double myArray[], int size){
for (int i =0; i
for (int j = i+1; j
if (myArray[i] > myArray[i]){
double temp = myArray[i];
myArray[i] = myArray[j];
myArray[j] = temp;
}
}
}
}
void readArray(double myArray[], int size) {
cout << "Please enter the " << size << " elements of the array: " << endl;
for(int i=0; i < size; i++) {
cin >> myArray[i];
}
}
void printArray(double myArray[], int size) {
for(int i=0; i < size; i++) {
cout << myArray[i] << " ";
}
cout << endl;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!