0
0
Embedded Cprogramming~10 mins

Volatile keyword and why it matters 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 volatile integer variable named flag.

Embedded C
volatile [1] flag;
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 use the volatile keyword.
2fill in blank
medium

Complete the code to declare a pointer to a volatile unsigned char named ptr.

Embedded C
volatile [1] *ptr;
Drag options to blanks, or click blank then click option'
Aint
Bchar
Cunsigned char
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Placing volatile after the asterisk.
Using signed char instead of unsigned char.
3fill in blank
hard

Fix the error in the code by completing the declaration of a pointer to a volatile int named p.

Embedded C
[1] int *p;
Drag options to blanks, or click blank then click option'
Aint volatile
Bvolatile int
Cint
Dvolatile
Attempts:
3 left
💡 Hint
Common Mistakes
Writing int volatile *p; which is valid but not the expected style here.
Omitting the volatile keyword.
4fill in blank
hard

Fill both blanks to complete the code that declares a pointer to a volatile int named vp.

Embedded C
[1] [2] *vp;
Drag options to blanks, or click blank then click option'
Avolatile
Bint
Cvolatile int
Dint volatile
Attempts:
3 left
💡 Hint
Common Mistakes
Putting volatile int together in one blank (not allowed here).
Swapping the order of volatile and int.
5fill in blank
hard

Fill all three blanks to complete the code that declares a pointer to a volatile unsigned int named vup.

Embedded C
[1] [2] [3] *vup;
Drag options to blanks, or click blank then click option'
Avolatile
Bunsigned
Cint
Dsigned
Attempts:
3 left
💡 Hint
Common Mistakes
Using signed instead of unsigned.
Omitting the volatile keyword.