Sales Bar Chart

I am writing a program that asks the user to enter sales for five stores and should have a bar graph below right now I dont have the bargraph labeled I just want to make sure my astericks are correct first. For some reason my code is not moving the astericks so I must have programmed something wrong with them because when I try sales[0], sales[1], etc at the bottom it will at least pull the output that I typed in.
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
  #include<iostream>
#include <string>
using namespace std;

int main()
{
	//Declare variables;
	int sales[5];
	int storeNum;
	string temp;
	
	for (storeNum = 0; storeNum < 5; storeNum++)
	{
		cout << "Enter the total sales for store " << storeNum + 1 << ": ";
		cin >> sales[storeNum];

		for (int i = 1; i <= sales[storeNum] / 100; ++i)
		{
			temp = sales[i];
			sales[i] = '*';
		}
		

	}

	cout << endl << temp[0] << endl << temp[1] << endl << temp[2] << endl << temp[3] << endl << temp[4] << endl;;
	
	return 0;
}
The sales array holds integer types - at line 20 you're trying to put the * character into the integer array.

line 17 - if you start i at 1 - you're going to miss store 1's data which is in the 0 element of sales array.

Also line 17 - sales[storeNum] / 100 - what if they have sales of 640 (or really, anything over 499). The largest i can be at line 19 is 4 because the array has 5 elements (0,1,2,3,4).
Topic archived. No new replies allowed.