The question :
Write a program that will initialize an array of charters to “do be do bo”. The program will call function Statistics() to output a list of all letters that occurred in the array together with the number of times each letter occurs in the array.
The output should look similar to:
The array is: do be do bo
Letter Number of occurrence
d 2
o 3
b 2
e 1
Letter ‘o’ has occurred the most.
The function prototype is:
void Statistics (char a []);
My program:
#include <iostream>
#include<iomanip>
using namespace std;
void Statistics (char a []);
int main()
{
char d[]="do be do bo";
Statistics(d);
return 0;
}
void Statistics (char d [])
{
int freq[26] ={0};
int i=0;
while ( d[i]!='\0')
{
if (d[i]==' ')
{
i++;
continue;
}
else
(freq(d[i]-97))++; //ERROR ONE called object type int is not a function
i++;
}
for (int j=0; j<26; j++)
{
cout<<setw(10)<<"Letter"<<setw(20)
<<"Number Of Ocurance\n";
cout<<setw(10)<<d[j]<<setw(20)<<
freq(d[i]-97); // ERROR TWO called object type int is not a function