Computers and Technology

Suppose we number the bits in a 32-bit word from 0 (least significant) to 31 (most significant). Write code for the following C function that will return 1 if x has at least one bit with a value of 1 at an odd index, 0 otherwise: int oddBit(unsigned int x);
Here are some test runs:

oddBit (Oxl): 0 oddBit (0x2): 1
oddBit (0x3): 1 oddBit (0x4): 0
oddBit (0x): 1
oddBit (Ox): 1
oddBit (Ox55555555): 0

Use only bitwise and logical operators (&&, 11, !); no if statements, loops, arithmetic operators (+,-, *,7,%), or conditional operators (==, !=, etc). Also write a main() function to test your function. Hint: use a bit mask to isolate the odd bits, and think about the effect of a logical not (or two) on an int in C. Comment your code, including every line that uses a bitwise operator.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, bargasdevon123
To insert a column without using commands in any tabs, a user can -click and then click insert column.
Answers: 3
image
Computers and Technology, 22.06.2019 09:00, sabahfayaskhan
Which best describes the condition under which the unicode output is the same as plain text?
Answers: 3
image
Computers and Technology, 23.06.2019 21:40, minnie7760
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
image
Computers and Technology, 23.06.2019 23:00, minosmora01
How do you know if the website is secure if you make a purchase
Answers: 2
Do you know the correct answer?
Suppose we number the bits in a 32-bit word from 0 (least significant) to 31 (most significant). Wri...

Questions in other subjects: