having trouble

its saying sales is an unitilized local variable can you tell me why
1
2
3
4
5
6
7
8
9
int strs, y, x, sales;
	for (x = 1; x < 6; x++)
		cout << "Stores" << x << ":\n";
	cout << "Sales Bar Chart\n";	
	strs = sales / 100;
		for ( y = 1; y <= strs; y++)	
			cout << "stores";
	   cout << endl;
	return 0;
Sales is unitialized because you never assigned a value to it. that means it could be any value at all.

Because of that, when you write this:
 
strs = sales / 100;

you're basically saying this:
 
stras = anyValueAtAll() / 100;   //who knows what this could be??? 
Last edited on
Topic archived. No new replies allowed.