+ 1

int a =100,b=200;while(++a<--b);sout("the average number is "+a);

What is the mechanism by wich this code averages value?

2nd Jun 2020, 2:49 PM
EMma♊
5 Answers
+ 3
To get an average, we usually sum some numbers, and then divide the sum by some range distance or data count. But here, I don't understand how your code can generate an average value, since no number appeared to be summed and divided. Next time you ask a question about a code, please save the code in SoloLearn and share the saved code link in your thread Description using the steps described on the following guide https://www.sololearn.com/post/75089/?ref=app (Edited)
2nd Jun 2020, 3:03 PM
Ipang
+ 2
Modify it like this while(++a < --b) { System .out.println(a +" < " +b); } then you can see how it can find average
2nd Jun 2020, 3:51 PM
zemiak
+ 1
Thank you for information.
2nd Jun 2020, 3:11 PM
EMma♊
2nd Jun 2020, 3:27 PM
EMma♊
0
Thank you for the answer
2nd Jun 2020, 4:16 PM
EMma♊