- 2

Sum & Mean

Read numbers from the user until -1 is encountered.And then find the sum and mean of the given numbers Read numbers from the user until -1

20th Nov 2021, 5:05 AM
Bobbanapalli Pradeep Kumar
3 Answers
+ 6
Bobbanapalli Pradeep Kumar , what programming language you are going to use? in general: ▪︎we can do the mentioned task by using a loop ▪︎we need a variable e.g. total that can take the running sum ▪︎we also need a counter variable for counting the number of input values ▪︎the input values has to be taken inside the loop ▪︎we have to check the input: - if input is -1, exit the loop - otherwise take the input value and add it to total - increment the counter variable ▪︎after terminating the loop the mean can be calculated by dividing the sum by the number of inputs
20th Nov 2021, 6:59 AM
Lothar
Lothar - avatar
20th Nov 2021, 5:33 AM
MATOVU CALEB
MATOVU CALEB - avatar
20th Nov 2021, 7:02 AM
Bobbanapalli Pradeep Kumar