0

In c programming How can I find the most appeared digit in array

Pls....help me code implementation Take an array of elements as an input from the user; find the most appeared digit in the array. Example: Input: array [10] = {234, 345, 453, 556, 355, 298, 56578, 198, 5, 65} Output: The digit 5 appeared 10 times.

4th Jul 2018, 8:49 AM
Lakshmi Lakki
Lakshmi Lakki - avatar
1 Resposta
+ 4
How far have you done trying Lakshmi Lakki? here's some hints to help you with: - Have a 10 elements array to be used to count appearance of digit 0-9 e.g. <counter>. - Use a while loop with modulo and division operator to extract each digit of each number in your numbers array. - Use the extracted digit as index of <counter> array element whose value to be incremented. - Finally, use a for loop to get the most frequent digit from <counter> array. Best of luck : )
4th Jul 2018, 12:13 PM
Ipang