subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Requirement types discussed during software development include functional and color scheme nonfunctional and code style constraint and nonfunctional fashionable and functional.
Answers: 2
question
Computers and Technology, 22.06.2019 12:30
Some of the first computer games were created in the early 1970s by college students experimenting after hours to see what the were capable of doing.
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 24.06.2019 12:30
Why does the pc send out a broadcast arp prior
Answers: 1
You know the right answer?
Suppose we number the bits in a 32-bit word from 0 (least significant) to 31 (most significant). Wri...
Questions
question
English, 19.05.2020 15:02
question
Mathematics, 19.05.2020 15:02
question
Mathematics, 19.05.2020 15:02
question
English, 19.05.2020 15:02
question
History, 19.05.2020 15:02
question
Mathematics, 19.05.2020 15:02
question
Mathematics, 19.05.2020 15:03
Questions on the website: 13722363