, , , ,

[SOLVED] Cop 2220 assignment 4

$25

File Name: Cop_2220_assignment_4.zip
File Size: 197.82 KB

Categories: , , , , Tags: , , , ,
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

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cop 2220 assignment 4
$25