Question: Assume data type int is 32 bits long and uses a twos-complement representation for signed values. Right shifts are performed arithmetically for signed values and

Assume data type int is 32 bits long and uses a two’s-complement representation for signed values. Right shifts are performed arithmetically for signed values and logically for unsigned values. The variables are declared and initialized as follows:

int x = foo(); /* Arbitrary value */ int y = bar(); /* Arbitrary value *

For each of the following C expressions, either 

(1) Argue that it is true (evaluates to 1) for all values of x and y, or 

(2) Give values of x and y for which it is false (evaluates to 0):

A. (x > 0) || (x-1 < 0) B. C. (x * x) >= 0 D. x < 0 11 x 011-x >= 0 F. x+y == uy+ux G. x*-y + uy*ux == -x (x

int x = foo(); /* Arbitrary value */ int y = bar(); /* Arbitrary value *

Step by Step Solution

3.44 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

These C puzzle problems provide a clear demonstration that programmers ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!