Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a single line of C code to implement each of the following. Assume the fol

ID: 3790625 • Letter: W

Question

Write a single line of C code to implement each of the following. Assume the following declarations, unsigned char ch; unsiqned int n; Example: For ch, check if bit 0 is set to 1 if (ch & 0times01) Clear bits 5, 3, 1 of ch, and preserve the remaining bits. For ch, check if any of bits 7, 6, 4, 1 are Set to 1. For n, Set bits 30, 27 to 24, Clear bits 15, 7 to 0, Toggle bits 21, 20, and preserve the remaining bits (Use Hex digits to specify the mask(s)) For n, check if all bits 31, 29, 27 are Set to 1, all bits 16, 14, 12, 11 are Cleared to 0, any of bits 7, 6, 2 are Set to 1, any of bits 24, 10, 8 are Cleared to 0. (Use Hex digits to specify the mask(s)) For unsigned int data type, operation byte-scramble is defined as follows, Write one line of C code to byte-scramble the given unsigned int n.

Explanation / Answer

a. clear bits 5,3,1 of ch

b.

if((ch &(10000000)!=0)||(ch&(01000000)!=0)||(ch&(00010000)!=0)||(ch&(00000010)!=0)

c. for 32 bit integer n

(((n | 4F000000) & FFFFBF80) ^ 300000) or operation set bits as 1 ,and operation clear bits , exclusive OR toggle bits

d. if((n| AFFFFFF==FFFFFFFF) // check all 31 29 27 bits are set to1

&&(n & 15800==0 ) //check 16,14,12,11 are cleared

&&((n|FFFFFF7F==FFFFFFFF)||(n|FFFFFFBF==FFFFFFFF)||(n|FFFFFFFB==FFFFFFFF)||(n| FFFFFFFD==FFFFFFFF)) //check 7,6,2,1 any bit is set to1

&&(n&1000000==0)||(n&400==0)||(n&100==0)) //check 24,10,8 any bit is cleared

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote