Question: One line of code in C for each problem, where you can only use straight-line code: use all the variables you want and write successive

One line of code in C for each problem, where you can only use straight-line code: use all the variables you want and write successive assignment statements, but no branching, ternary operators (?:), looping, or function calls. each puzzle restricts you to a short list of operators, (legal ops) each puzzle restricts you to maximum number of operator uses. (assignments actually don't count!) (max ops) you may only use one-byte constants. (valid: int x = 0xFF;)

1. returns 1 if x is the maximum, two's complement number, * and 0 otherwise * Legal ops: ! ~ & ^ | + * Max ops: 10 */

2. * return a value of -1 * Legal ops: ! ~ & ^ | + << >> * Max ops: 2 */

3. - return maximum two's complement integer * Legal ops: ! ~ & ^ | + << >> * Max ops: 4

4. - return 1 if all even-numbered bits in word set to 1 * where bits are numbered from 0 (least significant) to 31 (most significant) * Examples allEvenBits(0xFFFFFFFE) = 0, allEvenBits(0x55555555) = 1 * Legal ops: ! ~ & ^ | + << >> * Max ops: 12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!