logo CodeStepByStep logo

most_frequent_digit

Language/Type: C arrays tallying
Author: Allison Obourn (on 2020/09/14)

Write a function most_frequent_digit that takes a number as a parameter and returns the digit value that occurs most frequently in it.

For example, the number 669260267 contains: one 0, two 2s, four 6es, one 7, and one 9. most_frequent_digit(669260267) returns 6. most_frequent_digit(57135203) returns 3.

If there is a tie, return the digit with the lower value.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.