|
INTERVIEW QUESTIONS
C
VARIABLES IN C
DETAILS
Question: Can a variable be both constant and volatile ?
Answer: Yes. 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, in the example in FAQ 8, 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.
|
|
|
Category |
Variables in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 8531 users |
Added on |
9/18/2014 |
Views |
66074 |
Rate it! |
|
|
Question:
Can a variable be both constant and volatile ?
Answer:
Yes. 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, in the example in FAQ 8, 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. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
Can static variables be declared in a header file ?
|
View Answer
|
|
What does static variable mean?
|
View Answer
|
|
What are the advatages and disadvantages of binary floating point representation?
|
View Answer
|
|
Difference between : - 1)Global variable and Local variable , 2)Static variable and Global variable ?
|
View Answer
|
|
What is difference between static and global static variable?
|
View Answer
|
|
Constant volatile variable declaration is possible or not? if give any one example and reason.
|
View Answer
|
|
How pointer variables are initialized ?
|
View Answer
|
|
What is a pure virtual function?
|
View Answer
|
|
Are the variables argc and argv are local to main()?
|
View Answer
|
|
What are comment line arguments in C programiing? and also give an example.
|
View Answer
|
|
How much memory does a static variable takes?
|
View Answer
|
|
A variable carries a value.(already assigned OR from Scanf..what ever the way). I want to know whether the variable is positive or negative. Conditions: ----------- 1.NO looping logic should be used such as for ..while..etc.
2.should not use > or <.
3.should not use any numbers except 0. We can use 0 and equality operator. How to know the number is positive or negative?
|
View Answer
|
|
How much memory does a static variable takes?
|
View Answer
|
|
Where does global, static, local, register variables, free memory and C Program instructions get stored?
|
View Answer
|
|
1)What is static identifier?
2)Where are the auto variables stored?
|
View Answer
|
|
What is the benefit of using const for declaring constants?
|
View Answer
|
|
What is the difference between declaring a variable and defining a variable?
|
View Answer
|
|
What is an lvalue?
|
View Answer
|
|
Can static variables be declared in a header file?
|
View Answer
|
|
Can a variable be both const and volatile?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Variables in C Interview Questions & Answers - Exam Mode /
Learning Mode
|