Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Different formulas for mathematical core areas.

Answered: 1 week ago