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.

/*

* bitNand - ~(x&y) using only ~ and |

* Example: bitNand(0x6, 0x5) = 0xFFFFFFFB

* Legal ops: ~ |

* Max ops: 8

* Rating: 10

*/

int bitNand(int x, int y) {

return 2;

}

/*

* middleBits - return word with bits 15 and 16 set to 1.

* Legal ops: ! ~ & ^ | + << >>

* Max ops: 8

* Rating: 10

*/

int middleBits(void) {

return 2;

}

/*

* getByte - Extract byte n from word x

* Bytes numbered from 0 (LSB) to 3 (MSB)

* Examples: getByte(0x12345678,1) = 0x56

* Legal ops: ! ~ & ^ | + << >>

* Max ops: 6

* Rating: 8

*/

int getByte(int x, int n) {

return 2;

}

/*

* 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

*/

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!