Finding the mean of an array

I'm trying to find the mean of an array which the size and numbers are declared by user. I'm getting the error "invalid lvalue in assignment." Any help is appreciated.


1
2
3
4
5
	int meanValue = 0;			////finding the mean
	for (int y = 0; y < sizeOfNumberArray; y++){
		((numberArray[y]) + (numberArray[++y]) + meanValue) = meanValue;
		y++;
	}
I do not understand what statement

((numberArray[y]) + (numberArray[++y]) + meanValue) = meanValue;

means but un any case you may not assign any value to the temporary expression ((numberArray[y]) + (numberArray[++y]) + meanValue)
Last edited on
numberArray[++y] <--- Can be replaced with numberArray[y+1]

Also listen to what vlad said

EDIT: Also what is line 4 doing? If you are getting a segmentation fault error, I am not surprised because you seem to be wildly incrementing indexes
Last edited on
Thanks for the quick response. I was over complicating the issue. I figured it out though.

Thanks guys.
Topic archived. No new replies allowed.