I have this prog and what I need to do is have the user input their numbers and print the array, Then, for it to count the number of times the number was inputted and print a histogram of the number of times it was used. EX:
2.......10........3.5
4.......3.5 ..........21
3.........8...........7
//etc....
response ........# of times....... Histogram
1 .................... 2 ..................**
2 ................... 1 .......................*
//etc....
Here is what I have and I am unsure of the last few lines. I copied the last couple of lines from another example, I just included it because I know it will look somewhat to those lines. Please help, any help appreciated!
Code:
#include <iostream>
#include <iomanip>
using namespace std;
const int numrow = 5;
const int numcol = 3;
int main ()
{
double nums[numrow][numcol];
for (int i = 0; i <numrow; i++)
{
for (int j = 0; j < numcol; j++)
{
cout << "enter grades for row # " << (i + 1)<< ": ";
cin >> nums [i][j];
}
}
for (int a = 0; a < numrow; a++)
{
for (int b = 0; b < numcol; b++)
{
cout << setw (4) << nums [a][b];
}
cout << "Response" << setw( 13 ) << "Frequency"
<< setw( 17 ) << "Histogram" << endl;
for ( int i; i < numrow; i++ )
{
cout << setw( 7 ) << i << setw( 13 )
<< n[ i ] << setw( 9 );
for ( int j = 0; j < n[ i ]; j++ ) // print one bar
cout << '*';
cout << endl;
}
return 0;
}