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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started