My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Programming

Programming Programming Languages, Interpreters, and Compilers - Assembly, Declarative, Machine, Object Oriented, Iterative


Reply
 
LinkBack Thread Tools Display Modes
February 21st, 2013, 04:47 PM   #1
 
Joined: Feb 2013
Posts: 2
Little Man Computer question

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
cduval04 is offline  
 

My Computer Forum is free to register and we welcome everyone!

July 3rd, 2013, 09:20 PM   #2
 
Joined: Jul 2013
Posts: 4
Re: Little Man Computer question

What are you writing your program in? C++? If this is the case supply your code here so I can look at it. All you have to do is write a if statement or for loop that says get the users input until the user decides they want to stop giving input so maybe write a prompt saying"Enter your numbers, each seperated by a space, Press ENTER when you are done, "
Shamieh is offline  
July 4th, 2013, 03:30 PM   #3
 
Joined: Feb 2013
Posts: 2
Re: Little Man Computer question

Quote:
Originally Posted by Shamieh
What are you writing your program in? C++? If this is the case supply your code here so I can look at it. All you have to do is write a if statement or for loop that says get the users input until the user decides they want to stop giving input so maybe write a prompt saying"Enter your numbers, each seperated by a space, Press ENTER when you are done, "
no not c++ it was LMC assembly language....this assignment was due in february though lol...I got the first half of the question right..the other half I found out later...this was such a dumb assignment b/c like 50% of even IT professionals have never even heard of LMC..it exists to help teach the concept of programming, but it's outdated it just makes things more confusing imho..I took VB 2 years ago and understood it better than this..the class was IT problem solving..we did LMC..Alice..some excel problem solving analysis, VB and a little LUA..trying to cram 4 languages +excel into 1 semester was also kinda dumb...the course needs some revision imo...I got a B+ though...thanks for the help anyways...I will be taking C++ and java in the next few semesters, so I'm sure you have not seen the last of me. I'm enjoying my summer right now though.
cduval04 is offline  
December 30th, 2017, 12:58 AM   #4
Junior Member
 
Joined: Dec 2017
Posts: 1
C++ is perfect.
dineshcgokhale is offline  
Reply

  My Computer Forum > Computer Science Forum > Programming

Tags
computer, man, question



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ question...awesome question....challenging too !!! Vishal Srinivas Programming 2 November 5th, 2018 09:52 AM
Computer Science Question. Shamieh Computer Science 1 September 14th, 2013 05:27 AM





Copyright © 2018 My Computer Forum Forum. All rights reserved.