I write a program that count # of letters in a text file and now I need to tweak it a little bit using functions that:
1-take character as input parameter and returns its occurrence frequency in the input file
2-takes character as input parameter and returns its percentage of time it occurred in the input file.
3-display the character with the highest occurrence
4-display the character with the fewest occurrence
Well you already have option 1 done right? You just have to ask for which character they want to know about.
Option 2 is just taking the character the user input's count and dividing it by letter_count and multiplied by 100 for percent.
Option 3 is traversing through your frecount and seeing which is the highest.
Option 4 is the same as option 3, except you are looking for the lowest.
Options 3&4:
1 2 3 4 5 6
for(int max=frecount[0], min=frecount[0], inti=1; i<27; i++)
{
if(max<frecount[i]) max = frecount[i];
if(min>frecount[i]) min = frecount[i];
}
//note: this does not check if two or more characters tie for min or max counts
Your function returns type char. It will never return an int type variable. You shouldn't even ask the question how many, but rather which one is what you should be asking. Please, go and read the tutorial. Perhaps the parts about variable types, functions, and the general input and output I linked to earlier.