I am trying to get an float type average number from int inputs using the for loop. But it doesn't show me a correct answer. Could anyone tell me what i have done wrong? I think probably I made mistakes in this part,
for( int i = 0; i < size; i++ )
{
sum =+ myArray[ i ];
}
return static_cast< float >( sum ) / size;
I have attached picture so you can see the whole code.
Thank you for any advices
This line:
will apply unary
+
on right hand side value and then assign that tosum
, which is not what you want.You're looking for:
which will add the right hand side to
sum
.