Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Define a function named digitFrequency that returns how many times a given digit appears in a given integer n. The function prototype is as
a) Define a function named digitFrequency that returns how many times a given digit appears in a given integer n. The function prototype is as follows: int digitFrequency (int digit, int n); // precondition: digit is one of the 10 decimal digits For example, digitFrequency (3,1353) will return 2 because the frequency of 3 in 1353 is 2; digit Frequency (0, 0) will return 1; digit Frequency (3,-30003) will return 2; Note: you cannot use any C++ library functions. b) For this part, you need to write a main function/program that uses digit Frequency function you defined in part (a). Your program should ask the user for an integer, then display which decimal digit has the largest frequency in the user-input integer. For example, if the user enters -2686056, your program should display the following message: Digit 6 has the largest frequency which is 3 Note: You must use digitFrequency function you defined in part (a) to do this part
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