Question: INTEGER CODING RULES: Replace the return statement in each function with one or more lines of C code that implements the function. Your code must

INTEGER CODING RULES:

Replace the "return" statement in each function with one or more lines of C code that implements the function. Your code must conform to the following style:

#Comment how it works

int Funct(arg1, arg2, ...) { /* brief description of how your implementation works */ int var1 = Expr1; ... int varM = ExprM;

varJ = ExprJ; ... varN = ExprN; return ExprR; }

* anyEvenBit - return 1 if any even-numbered bit in word set to 1

* Examples anyEvenBit(0xA) = 0, anyEvenBit(0xE) = 1

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

* Max ops: 12

* Rating: 6

*/

int anyEvenBit(int x) {

return 2;

}

}

/*

* fitsShort - return 1 if x can be represented as a

* 16-bit, two's complement integer.

* Examples: fitsShort(33000) = 0, fitsShort(-32768) = 1

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

* Max ops: 8

* Rating: 6

*/

int fitsShort(int x) {

return 2;

}

/*

* oddBits - return word with all odd-numbered bits set to 1

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

* Max ops: 8

* Rating: 6

*/

int oddBits(void) {

return 2;

}

/*

* isGreater - if x > y then return 1, else return 0

* Example: isGreater(4,5) = 0, isGreater(5,4) = 1

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

* Max ops: 24

* Rating: 6

*/

int isGreater(int x, int y) {

return 2;

}

/*

* isPositive - return 1 if x > 0, return 0 otherwise

* Example: isPositive(-1) = 0.

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

* Max ops: 8

* Rating: 6

*/

int isPositive(int x) {

return 2;

}

/*

* replaceByte(x,n,c) - Replace byte n in x with c

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

* Examples: replaceByte(0x12345678,1,0xab) = 0x1234ab78

* You can assume 0 <= n <= 3 and 0 <= c <= 255

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

* Max ops: 10

* Rating: 6

*/

int replaceByte(int x, int n, int c) {

return 2;

}

/*

* absVal - absolute value of x

* Example: absVal(-1) = 1.

* You may assume -TMax <= x <= TMax

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

* Max ops: 10

* Rating: 6

*/

int absVal(int x) {

return 2;

}

/*

* isAsciiDigit - return 1 if 0x30 <= x <= 0x39 (ASCII codes for characters '0' to '9')

* Example: isAsciiDigit(0x35) = 1.

* isAsciiDigit(0x3a) = 0.

* isAsciiDigit(0x05) = 0.

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

* Max ops: 15

* Rating: 6

*/

int isAsciiDigit(int x) {

return 2;

}

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!