Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

Students also viewed these Databases questions

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago