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, 21.06.2019 18:20
Write a javascript program that reads three integers named start, end, and divisor from three text fields. your program must output to a div all the integers between start and end, inclusive, that are evenly divisible by divisor. the output integers must be separated by spaces. for example, if a user entered 17, 30, and 5, your program would output "20 25 30" (without the quotes) because those are the only integers between 17 and 30 (including 17 and 30) that are evenly divisible by 5.
Answers: 2
question
Computers and Technology, 22.06.2019 12:30
An atom's diameter is about 0.1 nanometer (1×10-9m), and a human hair is about 1×10-3m. how many times greater is a human hair than an atom's diameter? sorry pushed wronf button but this is math
Answers: 3
question
Computers and Technology, 22.06.2019 20:30
In this lab, you complete a prewritten c program that calculates an employee’s productivity bonus and prints the employee’s name and bonus. bonuses are calculated based on an employee’s productivity score as shown below. a productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Which is the highest level of the hierarchy of needs model? a. humanity b. intrapersonal c. team d. interpersonal
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
Questions on the website: 13722359