Question: Description: Write a C program that separates the digits of a positive integer 10 digits long and displays the result as a table of the
Description:
Write a C program that separates the digits of a positive integer 10 digits long and displays the result as a table of the number of occurrences of each digit. For positive integers whose digits are all different and do not include zero, the program should determine whether or not the input is divisible by each of its individual digits and display an appropriate message. See the sample output. Your program must use 5 functions. One for separating the digits, one for displaying the table of the number of occurrences of each digit, one for checking to see if all the digits are different, one for checking to see if the input is divisible by each of its digits, and finally the main function for interacting with the user. You may assume that the user will always enter an integer. However, your program must check the input. If it is a negative integer, the program should prompt the user for a positive integer.
Sample output
Enter a positive integer or 0 (zero) to end: 123 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 1 1 1 0 0 0 0 0 0 123 is not divisible by its digits. Enter a positive integer or 0 (zero) to end: 1000233 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 3 1 1 2 0 0 0 0 0 0 Wrong input for the second part. Input should not contain zero. Enter a positive integer or 0 (zero) to end: 12223 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 1 3 1 0 0 0 0 0 0 Wrong input for the second part. Input should not contain each digit more than once. Enter a positive integer or 0 (zero) to end: 248 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 0 1 0 1 0 0 0 1 0 248 is divisible by its digits. Enter a positive integer or 0 (zero) to end: 1248 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 1 1 0 1 0 0 0 1 0 1248 is divisible by its digits. Enter a positive integer or 0 (zero) to end: 98765432 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 0 1 1 1 1 1 1 1 1 98765432 is not divisible by its digits Enter a positive integer or 0 (zero) to end: 9867312 Digits: 0 1 2 3 4 5 6 7 8 9 Occurrences: 0 1 1 1 0 0 1 1 1 1 9867312 is divisible by its digits. Enter a positive integer or 0 (zero) to end: -2 Wrong input Enter a positive integer or 0 (zero) to end: 0 *** Program Terminated ***
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
