# 4.8: Exercises

Exercise $$\PageIndex{1}$$

Write a line of code that will print the statement “The result is x volts” where x is the value given by the floating point variable output_voltage.

Exercise $$\PageIndex{2}$$

Write a line of code to define a constant called RECIP2PI that is equal to 1/(2$$\pi$$).

Exercise $$\PageIndex{3}$$

Write the code to determine the number of bytes required for a variable called POWER_SUPPLY.

Exercise $$\PageIndex{4}$$

Assume the 8 bit variable X exists. Write the code to set the MSB (most significant bit), leaving all other bits unchanged.

Exercise $$\PageIndex{5}$$

Assume the 8 bit variable Y exists. Write the code to set the LSB (least significant bit), leaving all other bits unchanged.

Exercise $$\PageIndex{6}$$

Assume the 8 bit variable Z exists. Write the code to clear the MSB and LSB, leaving all other bits unchanged.

Exercise $$\PageIndex{7}$$

Assume the 8 bit variable W exists. Write the code to complement each bit (flip 0 to 1 and 1 to 0).

Exercise $$\PageIndex{8}$$

If X is 0x04 and Y is 0x09, what are:

a) X|Y

b) X&Y

c) ~X

d) 0xf1&Y

Exercise $$\PageIndex{9}$$

If X is 0xf0 and Y is 0x11, what are:

a) X|Y

b) X&Y

c) ~X

d) 0xf1&Y