Use the instructions provided I will rate the answer Name th
Solution
Please find the required program along with its output. Please see the comments against each line to understand the step.
#include \"stdio.h\"
char highestFreq(char *str){
int count=0,ct,i,j; //initialize variables
char c;
for(i=0; str[i]!=NULL; i++){ //iterate over the string : main loop
ct = 0; //set counter for current char as 0
for(j=i; str[j]!=NULL; j++){ //count the no:of occurence of current char
if(str[i]==str[j])
ct++;
}
if(ct > count){ //if current char\'s occurence is > count, then set count as current occurence and c as current char
count = ct;
c = str[i];
}
}
return c; //return c
}
int main(void) {
char hf = highestFreq(\"Hello World\");
printf(\"highestFreq char = %c\",hf);
return 0;
}
--------------------------------------------------------
OUTPUT;
