Question
Question 1: Implement a recursive function that counts the number of occurrences of a character in a string. The function declaration must be: /* *
Question 1:
Implement a recursive function that counts the number of occurrences of a character in a string. The function declaration must be:
/*
* Returns the number of occurrences of n in the string
* str, starting a position idx of str.
*/
int freq(string str, int idx, char n)
Use the newly defined function in a new program that prompts the user for a string and a character to look for in that string. No looping structure is allowed inside freq function.
Example 1:
The output should match the example below.
Please input a string: ThisIsAString
Please input a character to count: i
i occurs 2 times in a string of characters
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