Ok i've been staring at this code for over an hour and i cant figure out why it wont run properly.
What i'm trying to do is have a program that i've set values from 0 --99 in an array, i want to check the numbers and see wat the frequency of numbers are.
ie. 0-9 4 ( there are 4 numbers between 0-9)
10-19 5 ( there are 5 numbers between 10-19) and so on until 99
i want to display these in a histogram like
0-9 4 XXXX
10-19 5 XXXXX
...
90-99 2 XX
This is my code. Would anyone be able to tell me where i'm going wrong
Code:
#include <iostream>
using namespace std ;
void disp_chars (int freq, char ch) ;
void main ()
{ open main
int N =26;
int interval;
//float numbers[]= { 10, 12, 15, 16, 20, 25, 27,
29, 30, 36, 40, 42, 43, 50, 59,
61, 65, 67, 69, 72, 76, 77, 86, 90, 99 } ;
int count[10];
char ch = 'X' ;
disp_chars(5,ch);
cout << endl ;
for ( int i = 0 ; i < N ; i++)
{
interval =numbers[i]/10 ;
count[interval]++ ;
}
for( i=0; i<9; i++)
{
cout << i << " = " << count[i] <<endl ;
}
for( i=0; i<9; i++)
{
disp_chars(count[i],ch);
}
}//end main
void disp_chars ( int freq, char ch )
{
for ( int i=0; i<freq; i++)
{
cout << ch;
}
cout << endl ;
}