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

    5.3: Exercises

    Exercise \(\PageIndex{1}\)

    Assume a function declares a variable like so: static int x=0; The function increments the variable and then prints its value. What does the function print out on the tenth call to the function? How would this change if the static keyword was not used?

    Exercise \(\PageIndex{2}\)

    Consider the following snippet of code:

    void doug( void )
    {
        int x=0;
        
        x=x+1;
        printf( “%d\n”, x );
    }
    void dinsdale( void )
    {
        int x=20;
        
        x=x+1;
        printf( “%d\n”, x );
    }
    

    Suppose you call doug() five times in a row and then call dinsdale() five times in a row. What would the resulting output look like?


    This page titled 5.3: Exercises was last modified on Wed, 08 Sep 2021 02:57:24 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.