Hi i wrote some code to calculate the max value of an array or something like this but i couldnt find the error in the program but i think the pointer created in main function doesnt send the address to the fuction .Could you help me with this?
CODE IS HERE
Thank you for your advice but i can write code like this you wrote.However i am expected to write a program including a function which is in the form like double max(double *x[],int n).I wonder whether a function doing the same work can be wroten in thsi type.Thanks for your help...
double d = *(x[0]); // because x[0] is a pointer to a double
// So to visit every double you would need to dereference every double pointer in the array:
for(int i = 0; i < n; ++i)
{
if(*(x[i]) > max) { max = *(x[i]); }
}
So all you need to do is figure how to create such an array.
Remember you need an array of double pointers. Pointers to type double:
double* x[size];
So you need to allocate memory to every pointer in the array in which to store your doubles:
x[0] = newdouble; // allocate a double to element 0 of the double pointer array.
And you need to delete all those pointers afterwards:
delete x[0]; // delete element 0 of the double pointer array
Thanks for your support but this isnt the answer of my question because i must use a function like double max(double *x[],int n){ } .anyway.And Could you write your own code in the way of solution you describe??