1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

little man computer help

Discussion in 'Software Development' started by cduval04, Feb 21, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. cduval04

    cduval04 Thread Starter

    Joined:
    Feb 21, 2013
    Messages:
    1
    trying to write a program for school. the program is supposed to do the following:

    Write a program that takes an input value (for example, a number 5). The output should be sum of all numbers from 1 to the value input by the user (in this example, the output would be 1+2+3+4+5 i.e. 15)

    what I dont get is how if say I enter 20 how to get it to know that I entered 20 and just add all the numbers from 1 to 20 like count. would I use the SUB (subtract) command to aid in this? help-I'm stuck!!

    INP
    STA NUM1
    LDA NUM1
    INP
    STA NUM2
    LDA NUM2
    ADD NUM2
    OUT
    HLT
     
  2. kanaitpro

    kanaitpro Account Closed

    Joined:
    Feb 13, 2013
    Messages:
    493
    first of all what language are you using? i know c++, visual basic, python, and a little pascal. i may be able to point you in the right direction, but as you said it's a school assignment, i cannot give you an answer, just help you out with it by providing understanding.
     
  3. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    His thread subject says he is using Little Man Computer.
     
  4. kanaitpro

    kanaitpro Account Closed

    Joined:
    Feb 13, 2013
    Messages:
    493
    i've never heard of that. i will be of no use at all on this one, sorry.
     
  5. spatha

    spatha

    Joined:
    Jun 20, 2011
    Messages:
    82
    Does LMC have for loops? If so, that's how I would do it.

    in pseudo code:
    Code:
    for i to [input] do
    
    result = result + i
    
    end
    
    Something like that anyway.
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - little computer help
  1. charlzguitarz
    Replies:
    4
    Views:
    300
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1090520

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice