Hi,
I have to display the details inside an array as a bar chart, the user has input the temperatures for the twelve months, here is the declaration and the user input:

int temp[12];
int menuChoice;
char month[12][5]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

and the user input:

for(int count=0;count<12;count++)								
	{
		cout<<"Enter temp for "<<month[count]<<"=";
		cin>> temp[count];
	}

I want, somehow for the temperatures for each month to be displayed like a bar chart, for instance

Jan ***********
Feb ***** etc etc with a corresponding number for asterisks for the temperature.

Here's what I have so far

char graph = '*';
	cout<<"Temperature bar chart";
	for(int count=0;count<12;count++)
		{
			for(int b=0;b<int temp[count];b++)
				{
					cout<<graph;
				}
			cout<<endl;

		}

Is that anywhere near what it should look like?
Any help would be great!
Thanks

Lenny

You have the right idea, though the actual code you posted won't compile. I'd give you an example, but I can't do so without solving the problem for you, sorry.

Hey
The code up there is just a segment from the whole code, i just cant really work out how to make a bar chart from an array

>The code up there is just a segment from the whole code
It still won't compile. There's a syntax error in the inner for loop.

>i just cant really work out how to make a bar chart from an array
You posted all of the necessary logic to do it. Just put the pieces together. :icon_rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.