Lists – WSQ07

--Originally published at Programming in C++

For this program we had to ask the user for 10 numbers and saved the in a list. In this case I used arrays, but it can also be done with vectors. And then show to the user the total, average and standard deviation of those numbers.

wsq07f

Here are the 3 functions of the program (one for total, one for average, and one for standard deviation). The only new thing is putting arrays on them. Which is actually simple. You put the name of the array and then the size of it .

 

Now we have the main part:

wsq07m Here we have our array and its size. The size of the array is put between “[ ]”. Then there is a for for inserting the values. When talking about arrays we have to remember that it does not start counting in 1, it starts with 0, so that’s why our i starts there.

wsq07b