Setting up an array

Hey guys Im working on an assignment and its asking "Calculate the max, min, count, average, and standard deviation (std dev) of a set of numbers." The set up asks for you to enter a number then follows up with "Enter another?" where if you enter n it ends then prints out the above. So i'm trying to make an endless loop until you enter n into the second input. Can someone see if Im on the right track or do I need to re-think my setup?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

int main(){
	vector<int> myInts;
	vector<string> input;
	stringstream myStream;
	int x = 0;
	
	
	while(true)
	{
		for(int x = 0; x < 1000; x++)
		{
	
	cout <<"Enter a number:";
	getline(cin, input[x]);
	
	cout <<"Enter another?";
	cin >> value;
	
	if(value == n)
	{
		break;
		myInts.push_back(0); }
		
	for(unsigned int x = 0; x < input.size(); x++)
	{
		myStream.str(input[x]);
		myStream >> myInts[x];
	}
		}
			}
		
		return(0);
		 }
closed account (48T7M4Gy)
line 27 has no effect because it is preceded by break;

closed account (48T7M4Gy)
You also have compiler errors. None are the end of the world.
Why use strings team? cin, cout are sufficient.

You need to declare and initialize n by the look of it. The test at line 24 looks ok but what is n? is it an integer and if so is it 54 or 607 or ...

Creating an endless loop isn't hard... You don't always need to break out of it. Just set a condition that will fail.

While ( value != "n") {
// Handle your business
cin >> value
if (value=="n") {
Print your stuff
}

} Loop will end when condition is met. The condition of Value being = to "n"
Topic archived. No new replies allowed.