Answer the question and fill in the blank line below This is
Answer the question and fill in the blank line below( This is assembly language question):
What does the programmer what to find out from the following algorithm:
IF 2*(X÷2) = X THEN
BEGIN
EVEN := 1
END
IF 2*(X÷2) <> X THEN
BEGIN
ODD:= 1
END
___________________________________
Solution
The programmer want to find out, if X is even or not.
2*(X÷2) = X will be true only if X is an even number else X is odd number, same is being done in the given code. Note that, first division operator is executed and then multiplication by 2.
For example if X= 12, X÷2 = 6 , 2*(X÷2) = 12 = X
if X = 15, X÷2 = 7 Note that X is integer, dividing by 2 is also stored as integer
2*(X÷2) = 14 <> X
