Question: An integer n is divisible by 9 if the sum of digits is divisible by 9. Write a C program with an integer input parameter

An integer n is divisible by 9 if the sum of digits is divisible by 9.

Write a C program with an integer input parameter to display each digit in the input parameter with its sum, starting with the rightmost digit. The function should return the sum of the digits in the integer.

The main function should allow the user to enter positive integers until a negative number is input and also determine whether or not the positive integer is divisible by 9.

Test it on the following numbers: 154368, 621594, 123456.

A sample run would look like:

Please enter a positive integer (negative to end): 154368

The digits and sum are: 8 + 6 + 3 + 4 + 5 + 1 = 27

154368 is divisible by 9

Please enter a positive integer (negative to end): 123456

The digits and sum are: 6 + 5 + 4 + 3 + 2 + 1 = 21

123456 is not divisible by 9

Please enter a positive integer (negative to end): -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!