Nov 6, 2015 at 8:58am UTC
hallow everyone
how can I find the average from array that is taken 12 values
and how can I find the higher, lower, and equal to the average
using array of pointer
and dynamic array.
I did the array and I input values from user and I display it on black screen
and I stop at that steps above
becase I do not under stand it
- how can I calculate the average? and how can I mace comparison between values in array?
I hope to help me , and if you want me to show my code
I will do it
thank you.
Last edited on Nov 6, 2015 at 9:00am UTC
Nov 6, 2015 at 10:06am UTC
1 2 3 4 5 6 7 8 9 10 11 12
int higher = array[0];
int lower = array[0];
int average = array[0];
for (int i = 1; i != 12; ++i)
{
if (array[i] > higher)
higher = array[i];
else
if (array[i] < lower)
lower = array[i];
average += array[i];
}
Last edited on Nov 6, 2015 at 10:06am UTC
Nov 6, 2015 at 10:27am UTC
Thank you @Krogoth
Last edited on Nov 7, 2015 at 8:13am UTC
Nov 6, 2015 at 11:55am UTC
When posting code, please use code tags. Highlight the code and click the <> button to the right of the edit window.
One change: after the loop, add average /= 12;
Nov 6, 2015 at 4:09pm UTC
@dhayden
which loop did you mean?
here I have 3 for loop;
error LINK1168:cannot open
what is that mean?
Last edited on Nov 6, 2015 at 4:13pm UTC