PDA

View Full Version : reading from a list of numbers....and....



sssb2000
April 26th, 2005, 01:56 PM
hi,
i'm very new to c++ and was wondering if someone could help me with this:

i would like to ask the user to enter 10 numbers......
then i'd like to add these numbers ONE by ONE
then take the Standard Dev.
then take the Average.
then report it back to the user


could anyone help please :-(

BinaryBoy
April 26th, 2005, 02:25 PM
Is that homework?

There are better ways of doing this, but this should get you started.



#include <iostream>

int numbers[10];
for(int i = 0; i < 10; ++i) // Loop 10 times
{
std::cout << "Enter a number: "; // Display prompt
std::cin >> numbers[i]; // Get number from user
}

for(int i = 0; i < 10; ++i) // Loop 10 times
{
// Do stuff with each number[i]
std::cout << numbers[i] << std::endl
}