Skip to main content
Engineering LibreTexts

4.8: Exercises

  • Page ID
    35819
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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 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; a detailed edit history is available upon request.

    • Was this article helpful?