COP 2220 Assignment 4 solved

$25.00

Original Work ?

Download Details:

  • Name: Assignment4-u1csed.zip
  • Type: zip
  • Size: 440.93 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

An integer n is divisible by 9 if the sum of its digits is divisible by 9.
Develop a program that
1- Would read an input from the keyboard. The input should be a whole positive
number. (10 points)

2- Then display each digit, starting with the rightmost digit. (20 points)

3- At last decide if the number if divisible by 9 or not.
a. Calculate and display the sum of the digits. (10 points)
b. Display whether the input number is divisible by 9 or not. (10 points)

Hint: You would need to write a loop that extracts each digit in the number. Use the %
operator to get each digit; then use / to remove that digit.

As an example: 154368 % 10 gives 8 and 154368 / 10 gives 15436. The next digit extracted
should be 6, then 3 and so on.
Test your program on the following numbers:
n = 154368
n = 621594
n = 123456