Test questions and answers using the Little Man Computer (LMC)
Q1. Input 3 numbers, output the total
Q4. input a series of numbers and add, if 999 output total and stop
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.
Q5-13 Durham University