8.6: 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.

    8.6: Exercises

    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 was last modified on Wed, 08 Sep 2021 02:57:29 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.