Feb 14, 2013 at 6:38am UTC
I need to write a data input for one of my class assignment.
Would this be considered a data loop?
while (cin >> number)
If not would someone post an example of one.
Feb 14, 2013 at 6:48am UTC
I am not completely sure what you want, but from the looks of it, it seems you are learning about loops in general. I suggest you take a look at this
This should help you learn more about loops, but to be more exact, skip to the While Loop section and check out the example code there. It is pretty close to what you are probably looking for, so that should help.
Edit: Link should work.
Last edited on
Feb 14, 2013 at 7:22am UTC
Feb 14, 2013 at 6:57am UTC
The link that you posted is broken.
My assignment requires me count the number of user inputs and some calculations. The only problem I have is starting it up. It is supposed to look like this
Enter values: 54.53 94.18 66.4 66.5 done
[4 values, average=70.40, standard deviation=16.82]
Feb 14, 2013 at 7:30am UTC
I fixed the link, but I think you are going to need a few more things then just a loop. What code do you have so far?
Feb 14, 2013 at 7:38am UTC
This is what I have so far
int run(istream& cin, ostream& cout)
int count = 0;
//mean = 0;
average = 0;
cout << "Enter values: ";
//cin >> value;
//cout << "[";
while (cin >> value >> s)
average = (average + value) / count;
//mean = average / count;
cout << average;
if (s == "done")
cout << "[" << " values," << average << "average=" << ","
<< "standard deviation=" << "]";
I don't know how to count the users input.
Last edited on
Feb 14, 2013 at 7:39am UTC