Hey, guys. I'm new to this forum and this is my first post ever on this site. I am currently a freshman in Penn State University and I am having trouble with my C++ class. I have a group project but have no idea where to start with this program I have to make.
I am not asking for the code, I'm just asking for help so that I can actually start writing it and hopefully executing it correctly.
Here are the details:
P1. [Divisibility by 3 and 9]
Let n = akak-1ak-2 … a1a0 be a positive integer. Let s = ak + ak-1 + ak-2 + …+ a1 + a0
be a the sum of the digits of n. It has been proved that n is divisible by 3 and 9 if s is
divisible by 3 and 9.
Examples:
425175 is divisible by 3 because 4 + 2 + 5 + 1 + 7 + 5 = 24 and 24 is divisible by 3.
23454 is divisible by 9 because 2 + 3 + 4 + 5 + 4 = 18 and 18 is divisible by 9.
Write a C++ program that prompts the user to enter a positive integer and then uses this
criterion to determine whether the number is divisible by 3 and/or 9
Hints:
(1) A positive integer n is divisible by positive integer k if n%k == 0.
(2) 425175%10
5 and 425175/10
42517
the squares are arrows going to the right
When it gets to the akak, the second thing after the a's are all subscripts. I just need to know where to get started. Thanks everyone (: