C++
Suppose we are given the task of generating code to multiply
integer variable x by various different constant factors K. To be
efficient, we want to use only the operations +, -, and <<.
For the following values of K, write C expressions to perform the
multiplication using at most three operations per expression.
A. K = 17: B. K =− 7: C. K = 60: D. K =− 112:
Must obey bit integer coding rules:
(A)K=17
K = 16 + 1
X*K = X*(16) + X
X*K = (X << 4) + X
C expression
X = (X << 4) + X
(B)K=-7
K = 1 - 8
X*K = X - X*8
X*K = X - (X<<3)
C expression
X = X - (X << 3)
(C) K=60
K = 64 - 4
X*K = X*64 - X*4
X*K = (X << 6) - (X << 2)
C expression
X = (X << 6) - (X << 2)
(D) K=-112
K = 16 - 128
X*K = X*16 - X*128
X*K = (X << 4) - (X << 7)
C expression
X = (X << 4) - (X << 7)
C++ Suppose we are given the task of generating code to multiply integer variable x by...