I'm pretty new to C++, I'm a student in school. And I have this task I need to finish and submit soon. But this one question is still confusing me. Can someone help please.

Input 3-digit number and define

a. if the product of its digits is bigger than

b. if the sum of digits is multiple to 3

Input 3-digit number and define

a. if the product of its digits is bigger than

b. if the sum of digits is multiple to 3

one question is still confusing me |

What in it is confusing?

Can you handle input?

How do you study digits of a number?

To extract the digits out of an integer number, you need to know just a little bit about how modular arithmetic works, which is similar to division.

For example, say you have the number 123, and you're trying to get the last digit out of it (3). This can actually be done by finding the*remainder* when you divide 123 by 10.

123 / 10 is 12 (through Integer division, which essentially truncates 12.3), but the remainder of 123 when divided by 10 is 3.

In C++, this is calculated through the % ("modulo") operator.

**123 % 10** gives you a result of 3.

So, in general, you can get the least-significant digit of an integer by finding its remainder, modulo 10. And you can remove the least-significant digit by dividing by 10.

123 % 10 = 3

12 % 10 = 2

1 % 10 = 1

123 / 10 = 12

12 / 10 = 1

1 / 10 = 0

Try to work from and experiment.

For example, say you have the number 123, and you're trying to get the last digit out of it (3). This can actually be done by finding the

123 / 10 is 12 (through Integer division, which essentially truncates 12.3), but the remainder of 123 when divided by 10 is 3.

In C++, this is calculated through the % ("modulo") operator.

So, in general, you can get the least-significant digit of an integer by finding its remainder, modulo 10. And you can remove the least-significant digit by dividing by 10.

123 % 10 = 3

12 % 10 = 2

1 % 10 = 1

123 / 10 = 12

12 / 10 = 1

1 / 10 = 0

Try to work from and experiment.

Topic archived. No new replies allowed.