4.8: Exercises

Embedded Controllers Using C and Arduino · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC-SA 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    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


    This page titled 4.8: Exercises was last modified on Wed, 08 Sep 2021 02:57:26 GMT and is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by James M. Fiore via source content that was edited to the style and standards of the LibreTexts platform.