CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Can a variable be both const and volatile?
Category C Interview Questions
Rating (4.4) By 18 users
Added on 10/22/2004
Views 8651
Rate it!
Answers:

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.



The above answere refer to the const pointer. the question is about const variable. If you are using the const variable, then you shoud not combine it with volatile since volatile is supposed to change



 Posted by: bibin    

Contact bibin  Contact bibin

it is not possible to have a variable which is const and volatile...
const means its value cant be changed,but using pointers we can access address of variable and can change its value..
volatile means its value can be changed...



 Posted by: Nagamani    

Contact Nagamani  Contact Nagamani


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
How reliable are floating-point comparisons?
View Answer
How can you determine the maximum value that a numeric variable can hold?
View Answer
When should a type cast be used?
View Answer
When should a type cast not be used?
View Answer
Is it acceptable to declare/define a variable in a C header?
View Answer
What is the difference between declaring a variable and defining a variable?
View Answer
Can static variables be declared in a header file?
View Answer
What is the benefit of using const for declaring constants?
View Answer
What is the easiest sorting method to use?
View Answer
What is the quickest sorting method to use?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/1057/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.62