i m unable to undestandthe error in this plz help
Rainwater harvesting
Hello @Tiya,
-
You have not declared min[] and max[] array.
-
How are you so sure that there would not be more than 100 elements in the array?
Solution:
2.1. First take input n.
2.2. Then, declared these array with size n i.e. int arr[n]; -
Logic for lmax is wrong and time consuming also.
Solution:
3.1. First make lmax[0]=b[0]
3.2. Compare lmax[i-1] with b[i] for 0>i<n and assigning the greater value to lmax[i]
. -
The logic for rmax is also wrong.
Solution:
4.1. rmax[n-1]=b[n-1];
4.2. And check the values of array from last and compare max[i+1] with b[i] and assigning the greater value to lmax[i].
Reason for 4th and 5th point:
lmax is increasing and rmax is decreasing.
Hence, in an increasing sequence, if the value at ith index is greater than value at (i-1)th index then it is automatically greater than the values at index less than i. -
Rest of the logic is correct.
Hope, this would help.
Give a like, if you are satisfied.
still getting the same error
what is unresolved overloaded function error?
Hey @Tiya,
Why unresolved overloaded function error?
min is a predefined function which is used to find minimum value of two of its parameters.
Syntax:
int min(int a, int b);
returns: minimum of a and b.
You didn’t declare the min array. So, it was causing an error as compler is checking for the min() function that I have explained above.
Overlading is a concept that you would learn in your course. It would then be easier for you to understand this error.
I have modified your code:
Hope, this would help.
Give a like, if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.