Question
In C complete each of the functions using only straightline code no loops or conditionals and only using the legal operators listed for each function.
In C complete each of the functions using only straightline code no loops or conditionals and only using the legal operators listed for each function.
/*
* allOddBits - return 1 if all odd-numbered bits in word set to 1
* Examples allOddBits(0xFFFFFFFD) = 0, allOddBits(0xAAAAAAAA) = 1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 12
* Rating: 6
*/
int allOddBits(int x) {
return 2;
}
/*
* conditional - same as x ? y : z
* Example: conditional(2,4,5) = 4
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 16
* Rating: 4
*/
int conditional(int x, int y, int z) {
return 2;
}
/*
* bitCount - returns count of number of 1's in word
* Examples: bitCount(5) = 2, bitCount(7) = 3
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 40
* Rating: 2
*/
int bitCount(int x) {
return 2;
}
/*
* minusTwo - return a value of -2
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 2
* Rating: 12
*/
int minusTwo(void) {
return 2;
}
/*
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