+ 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?
5 Réponses
+ 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)
+ 2
Modify it like this
while(++a < --b) {
System .out.println(a +" < " +b);
}
then you can see how it can find average
+ 1
Thank you for information.
0
Thank you for the answer