Redirected
324 views
1 votes
1 votes

Manisha is making a health app by monitoring the pulse rate of users. If she is using C code, what would be the most appropriate way to declare the variable beats which is having the count of the pulses?
 

  1. Volatile short int beats;
  2. Extern short int beats;
  3. Static char beats;
  4. Auto short int beats;

1 Answer

6 votes
6 votes

C's volatile keyword is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time--without any action being taken by the code the compiler finds nearby. 

Objects declared as volatile are omitted from optimization because their values can be changed by code outside the scope of current code at any time. The system always reads the current value of a volatile object from the memory location rather than keeping its value in a temporary register at the point it is requested, even if a previous instruction asked for a value from the same object. 

Answer:

Related questions

1 votes
1 votes
1 answer
3
1 votes
1 votes
1 answer
4