Skip to main content
Engineering LibreTexts

8.6: Exercises

  • Page ID
    35840
  • \( \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}\)

    Declare a pointer to a floating point variable, naming it fptr.

    Exercise \(\PageIndex{2}\)

    Declare a pointer to a signed character variable, naming it cptr.

    Exercise \(\PageIndex{3}\)

    Consider the following snippet of code:

    unsigned char c, *p;
    

    Explain the difference between c and p.

    Exercise \(\PageIndex{4}\)

    Consider the following snippet of code:

    unsigned char *p;
    double *p2;
    

    Assume that the value of p is currently 1000 and the value of p2 is 2000. What are their values after the following piece of code is executed?

    p++;
    p2++;
    

    Exercise \(\PageIndex{5}\)

    Explain the difference between the * and & operators in relation to pointers.

    Exercise \(\PageIndex{6}\)

    Consider the line of code below.

    a = b*c;
    

    Is the * operator a pointer dereference or a multiply? How do we know?

    Exercise \(\PageIndex{7}\)

    Consider the line of code below.

    a = b**c;
    

    What do you think this line does? How might you alter this line to mark the intent more clearly and less prone to error or misinterpretation?

    Exercise \(\PageIndex{8}\)

    Explain the difference between the two lines of code below.

    a*=b;
    a=*b;
    

    This page titled 8.6: 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?