Question: Write a C program that asks the user for a positive integer and checks whether the value is divisible by 11 using the following algorithm:

Write a C program that asks the user for a positive integer and checks whether the value is divisible by 11 using the following algorithm: As long as the number is more than one digit, shorten it by deleting the ones digit and subtracting this digit from the resulting number. The original number is divisible by 11 if and only if the final number is equal to zero. You should check whether the initial value entered is positive, and if not ask the user to enter another number until valid input is received. Your output should include the intermediate values computed at each step of the algorithm followed by a statement indicating the result. Sample input/output: Enter a positive integer 48070 Checking if 48070 is divisible by 11... 48070 4807 473 44 0 48070 is divisible by 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
