60 469
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #8307 in C++ for Eugine

Question #8307
an algorithm to find the average of the numbers in a linked list of numbers
Expert's answer

To find the average of numbers in a linked list you should calculate the total number of this numbers (N), calculate the sum of all this numbers (Sum). So the
expected value is Sum / N.



list l;

int sum = 0;

int n = 0;

while (l.next != 0) {

sum += l.number;

n++;

l = l.next;

}

return (float) sum / n;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions