Skip to content

Mbyrne28/Little-Man-Computer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Little Man Computer

Test questions and answers using the Little Man Computer (LMC)

Background

Wikipedia on LMC

Questions

Q1. Input 3 numbers, output the total

Q2. Count down from 5-0

Q3. Count up from 1-5

Q4. input a series of numbers and add, if 999 output total and stop

Q5. Output the first n Fibonacci numbers. Your program should take the input n and then output the first n elements of the sequence. I.e. 1, 1, 2, 3, 5

Q6. Take two inputs a, b and compute a × b.

Q7. Input a and compute a divided by 2.

Q8. Input a and b and compute a divided by b.

Q9. Take inputs until an input of 0 is received, then output the smallest of the inputs.

Q10. Take two inputs and output the highest common factor (look up Euclid's algorithm )

Q11. Basic objective: Create a Little Man Computer program to take three inputs (a, b, and c) and determine if they form a Pythagorean triple (i.e. a^2+b^2=c^2). Your program should output a zero (000) if the inputs are not a Pythagorean triple, and a one (001) if the inputs are a Pythagorean triple.

Q12. Intermediate objective: Enhance your program to accept Pythagorean triples presented in any order, i.e. 3,4,5, or 5,3,4 or 4,5,3 would all be accepted (output 001), though obviously 3,4,6 in any order would not.

Q13. Advanced objective: Incorporate a check for any overflow, and use the output two (002) to indicate that the inputs are outside the range that your program can handle. Also ensure that the program runs successfully a second time if a run is stopped at any point of operation, or terminates normally, then the program counter is reset to zero and the LMC is run again.

Reference

Ian! D. Allen

Online LMC simulator

Citations

Q5-13 Durham University

About

Test questions and answers using the Little Man Computer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages