Question
Programming in C Write a function called maximum_occurences() that accepts a pointer to a string (consisting of alphanumeric and whitespace characters only), a pointer to
Programming in C
Write a function called maximum_occurences() that accepts a pointer to a string (consisting of alphanumeric and whitespace characters only), a pointer to an array of struct occurrences, a pointer to an integer, and a pointer to a character as arguments. The structure is defined as follows:
typedef struct occurrences
int num_occurrences;
double frequency;
} Occurrences;
The function determines the frequency of each character found in the array. The frequency is defined as: number of one character symbol / total number of characters. The function should use the second array argument (of struct occurrences) to keep track of the frequency of each character. Also, it must return, through the pointers, the maximum number of occurrences of any one character and the corresponding character for which the maximum represents. Thus, for a string such as test string, t occurs 3 times, which is the maximum occurrences for any one character in the string.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started