I do not have any code to provide, mainly because my teacher is not good so I have no clue where to start. But for example if you chose 3 and 20 then it would add up 3, 7, 11, 15, 19 to display the sum of 55. What would be the basis of writing this code? What would be the language you would use? Please give an example of how to do it. It would be greatly appreciated.
How would you write a code to add every 4th number between 2 values entered by the user?
73 Views Asked by michaelmahoney At
1
There are 1 best solutions below
Related Questions in LC3
- Installing the C compiler for LC3
- LC-3 Assembly OR operation
- I am unsure about LC-3 NOP
- LC-3 Assemby Counters
- Assembly - Prime/Not Prime - LC3
- How to return from HALT in LC3?
- How can I take multiple digit positive integers as input in LC3?
- How can I print a multiple-digit decimal number stored in a register in LC-3 assembly?
- LC-3 Program: Tracing the Execution
- Is there a reason this LC-3 subroutine keeps looping?
- LC-3 Assembly Calculator
- How do I modify my code to compare the user input against "QUIT" and have it exit the loop if they don't match?
- LC-3 program with 3 bugs (2 syntax and 1 logic)
- LC-3 Assembly Code isn't processing user's input correctly
- What is the equivalent of .WORD in LC3?
Related Questions in LC3-TRAP
- How Do I Use User Input To Make An Array Of 8 With Ranges 0-100?
- LC3 Help - not printing the amount I want to print
- How to develop an intuition to code in LC-3 Assembly?
- How to produce double digits numbers LC3
- Printing double digit numbers in LC-3
- How would you draw a vertical line in an LC-3 simulator like Pennsim?
- How would you write a code to add every 4th number between 2 values entered by the user?
- Write an LC-3 assembler in LC-3 assembly (just handling mnemonic -> opcode, not operands)
- Efficient LC3 assembly code to print the numbers leading up to any digit, unit test says mine is too inefficient
- LC3 - Compute Square Assembly
- LC3 Assembly Square of N
- LC3 Subroutine - Custom Trap Routine
- LC-3 Instruction Understanding
- Incorrect Value in Register After Run LC3 Assembly
- LC3 continue getting a trap was executed with an illegal vector number
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Using your example:
You need a variable that holds the total sum which initially will be zero, another one to keep track of the current number, and another one to know if you are on a 4th number.
You need a loop that starts in 3 and finishes on 20, and you need to track the current number with one of the already mentioned variables.
In the loop you will go incrementing the current value, and also the variable to know if your are on a 4th number (if it starts in 1, when it reaches 4, you are on a 4th number).
Every time you are on a 4th number, you will have to add the current value to the total sum, and reset the 4th number count to knwo when you reach the next one.
I hope this helps you with your homework.