LearnFrenzy
Sign in Take a free test

Declarations and Initializations · Declarations MCQ · Question 11

What does volatile mean in a declaration? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What does volatile int status; tell the compiler?

  • A status cannot change
  • B status may change outside the program's control, so every access must actually read or write memory Correct
  • C status is stored in a register
  • D status is shared safely between threads
Correct Answer: Option B

volatile stops the compiler from caching the value or removing "redundant" accesses – needed for hardware registers and signal-handler flags. It does not make access atomic or thread-safe.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links