I have a problem. I have this code but the problem is how do i put the results in a histogram form.
Can someone please help.

#include <iostream>
using namespace std;
int main()
{
    const int arraySize=30, rangeSize=9;
    int gross_Sales[arraySize]=
    {   2430, 3500, 9400, 14300, 4200, 1250,
        9990, 5410, 5400, 6780, 3450, 10010,
        5460, 1110, 8760, 4630, 9050, 6710,
        6090, 4560, 7610, 10020, 11110, 5410,
        3450, 1980, 6320, 9780, 8990, 10020};
    int i, counter[rangeSize];
    double salary;
    for(i=0;i<rangeSize;i++)
        counter[i]=0;

    for(i=0;i<arraySize;i++)
    {
        salary = gross_Sales[i] * 0.09 + 200;
        if (salary<1000)
           counter[int(salary / 100) - 2]++;
        else
           counter[8]++;
    }

    int mindollar, maxdollar;
    for(i=0; i<8; ++i)
    {
        mindollar=i*100+200;
        maxdollar=mindollar+99;
        cout << "$" << mindollar << "-$" << maxdollar 
<< ": " << counter[i] << endl;
    }
    cout << "$1000 and over: "  << + counter[8] << 
endl;

    return 0;
}

>the problem is how do i put the results in a histogram form.

Are you saying you would like output something like this?

$200-$299  :  1 *
	$300-$399  :  2 **
	$400-$499  :  1 *
	$500-$599  :  4 ****
	$600-$699  :  6 ******
	$700-$799  :  2 **
	$800-$899  :  3 ***
	$900-$999  :  1 *
$1000 and over : 10 **********

If so, something similar to this would be a start.

void hist(int count)
{
   for (int i = 0; i < count; ++i)
   {
	  cout << '*';
   }
}

int main(void)
{
   /* ... */
   for ( i = 0; i < 8; ++i )
   {
	  mindollar=i*100+200;
	  maxdollar=mindollar+99;
	  cout << "$"  << mindollar << "-$" << maxdollar
		   << ": " << counter[i];
	  hist(counter[i]);
	  cout << endl;
   }
   cout << "$1000 and over: " << + counter[8];
   hist(counter[8]);
   cout << endl;
   return 0;
}
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.