2) Write the definition of a recursive function named find that is passed a c-string and a char and returns with the pos of the char if it finds the char within thec-string or returns -1 if the char is not found. You must implement the expected function, but you may write other code as long as your additional code helps find perform as expected. For example, if a cstring named cstr contains the value "this is my string" and a char named c containing the value 'i' is passed in to find, the function should return the value 2. However, if c contained the value 'a', then find would return -1. This is what the function call for the example above would look like: int foundat = find(cstr, c); NOTE: This function takes a c-string, NOT a string. No c-string functions may be invoked.
2) Write the definition of a recursive function named find that is passed a c-string and a char and returns with the pos of the char if it finds the char within thec-string or returns -1 if the char is not found. You must implement the expected function, but you may write other code as long as your additional code helps find perform as expected. For example, if a cstring named cstr contains the value "this is my string" and a char named c containing the value 'i' is passed in to find, the function should return the value 2. However, if c contained the value 'a', then find would return -1. This is what the function call for the example above would look like: int foundat = find(cstr, c); NOTE: This function takes a c-string, NOT a string. No c-string functions may be invoked.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning