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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!