Embedded System Question:
Download Job Interview Questions and Answers PDF
Explain Can we have constant volatile variable?
Answers:
Answer #1Const and volatile keywords should not be used together because both are opposite in nature.
A variable is declared as "const" means it's value is not able to be changed but if it is declared as "Volatile" then it is not under control.
A variable is declared as "const" means it's value is not able to be changed but if it is declared as "Volatile" then it is not under control.
Answer #2const represents the variable will not be modified by the code but volatile represents any external event can update the variable like time ticks from the processor
Answer #3Const volatile is a very special thing, it means that the program cannot modify the variable\\'s value, but the value can be modified from the outside, thus no optimisations will be performed on the variable.
for e.g. read-only hardware status register
for e.g. read-only hardware status register
Answer #4We can have. It is very much possible
Answer #5If the value of a variable in the prgm is to be maintained constant and not to be changed by any other external operation then wevdeclare the variable as,
Volatile const int mark = 100
Volatile const int mark = 100
Answer #6Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. For instance,take example the timer structure was accessed through a volatile const pointer. The function itself did not change the value of the timer, so it was declared const. However, the value was changed by hardware on the computer, so it was declared volatile. If a variable is both const and volatile, the two modifiers can appear in either order
Answer #7status registers are conts volatile variables which means the register is read-only 'const' and the value of it could be changed any time.
Download Embedded System Interview Questions And Answers
PDF
Previous Question | Next Question |
Explain Can structures be passed to the functions by value? | Explain What are the different storage classes in C? |