0
0
Embedded Cprogramming~10 mins

Static memory allocation patterns in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a static integer variable named 'counter'.

Embedded C
static [1] counter = 0;
Drag options to blanks, or click blank then click option'
Aint
Bfloat
Cchar
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using a floating-point type instead of an integer.
Forgetting to specify the data type.
2fill in blank
medium

Complete the code to declare a static array of 10 characters named 'buffer'.

Embedded C
static [1] buffer[10];
Drag options to blanks, or click blank then click option'
Aint
Bdouble
Cfloat
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using int instead of char for character arrays.
Forgetting the static keyword.
3fill in blank
hard

Fix the error in the static pointer declaration to point to an integer.

Embedded C
static [1] *ptr;
Drag options to blanks, or click blank then click option'
Afloat
Bint
Cchar
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using a floating-point type instead of int.
Omitting the asterisk (*) for pointer declaration.
4fill in blank
hard

Fill both blanks to declare a static constant array of 5 integers named 'values'.

Embedded C
static [1] [2] values[5] = {1, 2, 3, 4, 5};
Drag options to blanks, or click blank then click option'
Aconst
Bint
Cfloat
Dvolatile
Attempts:
3 left
💡 Hint
Common Mistakes
Using float instead of int.
Forgetting to use const for constant arrays.
5fill in blank
hard

Fill all three blanks to declare a static volatile pointer to a constant integer named 'ptr'.

Embedded C
static [1] [2] [3] * ptr;
Drag options to blanks, or click blank then click option'
Avolatile
Bconst
Cint
Dstatic
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of volatile and const.
Forgetting the asterisk (*) for pointer declaration.