Cso Assignmt
Cso Assignmt
GROUP
1.
43714
2.
43822
Introduction
C++ is a high level programming language. It features object-oriented and generic
programming which contribute the efficiency for low-level memory manipulation. It is useful in
many aspects such as desktop application, servers, performance-critical applications, and
entertainment software (Wikipedia, n.d.). C++ gives a collection of predefined classes with the
competency of user-defined classes. Class definitions determine data objects and functions.
Thus, it mainly used for software engineering and graphics.
Result
QUESTION 1
QUESTION 2
Compiler Log
First input 10
Second input 2
Highest common factor we cannot get.
IN
(first input)
STO a
(store input)
IN
(second input)
STO b
(store second input)
# Keep subtracting a from b until you go negative
# Keep a count of how many times you do it
start LDA count (load the number that had been minus for a and b)
ADD one
(add the input)
STO count (store the number that already count)
LDA a
(load the input a)
SUB b
(a subtract b)
STO a
(store a)
BRP start (branch continue if positive)
done LDA count (load number that have count)
# Subtract one as we went one too far
SUB one
(subctract the number again)
OUT
(output)
HLT
(stop)
a
DAT 000
b
DAT 000
count DAT 000
one
DAT 001
Discussion
In question 1, the program is very simple. It used the cmath and iostream to make it works.
The function like if,else and goto have been used in this program to make sure key in the
right value. Instructions also have been include in the program to guide the user.
Firstly, the user will have entered his S value, follow by entering the EE value and MMMMM
value. After that the program will calculate the mantissa and change it to 10s complementary.
For question 2, we have a bit problem to understand how to use Euclidean Algorithm. Based on example
given below:
From what we know, no division in LMC. To make a divide operation, we need to minus the
value example above 3084-1424.
As we can see, at the first, we plan to make a program that used two inputs of course, and
3084-1424=1660. Then 1660-1424=236 and if minus again the answer will be 0. So 236 we
stored the value. Next, 1424 will minus the value that we have stored until get 0 but not negative.
The answer we get if minus 1424 continuously by using loop will get 8. Thats mean the
COUNT is 6. But the solution is not finish. After we get 8 as a remainder, next the remainder 236
minus with remainder 8 until get 0 but the remainder we get is 4. Then, 8 minus 4 until
remainder get 0. If the remainder get 0, so that is the final answer. Therefore greatest common
divisor is 4 and COUNT is 4. But we cannot do this program because we lack of information
about coding although in the internet we still not get the information we want. We already do it
but always fail. Below is a picture that we want to establish our idea but failed.
Next, we have discussed with a few groups how to do the LMC program and we get it but we
still cannot get the greatest common factor but the COUNT probably correct. The result can be
seen on result on the other page.
Conclusion
In conclusion, for question 1, we have built a C++ program to convert SEEMMMMM to 10s
complimentary and for question 2, we already do the Little Man Computer program but the
problem is we cannot get the highest common factor.
Reference
1. https://www.rit.edu/~w-asc/documents/services/resources/handouts/DM%20%206%20Euclidean%20Algorithm.pdf
2. https://answers.yahoo.com/question/index?qid=20130618035050AApbNV8
3. http://www.ict4ocr.com/computing/lmc_blocks.html