- 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
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
+ 1
It looks like homework
Post your attempt here
https://code.sololearn.com/Wef9RvZrLfCT/?ref=app
https://www.sololearn.com/discuss/1316935/?ref=app