- 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
4 Respuestas
+ 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