To input two-digit numbers, simply read the first digit, multiply it by 10, and add on the second digit.

Please log in or register to post a reply.

Thank you I have the program running with 2 digit integer, but now I need to compute the sum of all the numbers that are multiples of three and print out the sum or if there are not multiples print out the prompt in in address error

ex: input

12, 11, 18, 23 00

the output will be

The sum of the multiples of three is 30

I would appreciate any help

Thank you

That sounds resonable but can you give an example using the program that
I have becuase I dont really know how to divide in assembly.

Please help me I would appreciated. Thank you.

If you wish and is not to much to ask you can test the program above using the LC-3 simulator you can download it for free in www.mhhe.com/patt2. Is the lc-3 simulator window version I am using that. Thank you for your help I really appreciate it.

An easy way to check for multiples of 3 is to add the digits of a number. If the result is a multiple of 3, so is the original number.

E.G.

96: 9 + 6 = 15, so 96 is a multiple of 3

62: 6 + 2 = 7, so 62 is not a multiple of 3

The largest 2-digit number, 99, makes 18 when you add the digits, so you only have to compare against a few numbers that can be hard-coded in: 3, 6, 9, 12, 15, and 18.

And using the same trick that Reedbeta mentioned, you can iterate the process until you have a single digit result. eg: 239912856 -> 2+3+9+9+1+2+8+5+6 -> 45 Now iterate again -> 4+5 -> 9. Viola! This way you only need to compare against 3, 6, and 9, just iterate until you are down to a single digit. Plus, you can check arbitrarily large numbers - AND you can accomplish the task in a mere 2 iterations for numbers up to 11 digits long or more (399999999999 finally requires three iterations).

Not that this is the only way to do it…

- Upcoming Multiplatform Game Program...
- Our first game - looking for feedbacks
- Network Emulation Tool
- Trouble with accessing GLSL array
- Fiction
- Game Programming Patterns: Bytecode
- Interactive WebGL Water Demo
- Skeletal Animation Tutorial with GP...
- Unreal Engine 4
- Microsoft xbox one selling poorly

Hello

I have to write a program that will input a list of positive 2-digit integrs and will compute the sum of all the numbers that are multiples of three and print out the sum. The numbers are to be input from the keyboard after a prompt is written on the monitor. The value zero will act as a sentinel value at the end of the data.

Well so far I have the program working with an input of a list of positives 1-digit integers; now I want you to help me to change the program so it will have a input of a list of 2-digit integers.

Please help me I really need your help. Here is the code that I have:

please I would appreciate your help. Thank you