Can a variable be both const and volatile?



Can a variable be both const and volatile?..

Answer / Ashish Kumar Tiwari

In C, it is not possible for a variable to be both 'const' and 'volatile'. The 'const' qualifier specifies that the value of an object should not be modified, while the 'volatile' qualifier indicates that the value of an object may be modified by means outside the program's control. Combining these two qualifiers would lead to a semantic ambiguity because if a volatile const were modifiable, it would not be constant and if it were not modifiable, it would not be volatile.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;

5 Answers   ITCO, Wipro,


What does the error message "DGROUP exceeds 64K" mean?

1 Answers   Celstream,


which of 'arrays' or 'pointers' are faster?

5 Answers  


what is different between auto and local static? why should we use local static?

1 Answers  


A C E G H +B D F A I ------------ E F G H D

1 Answers   Infosys,


Write a program of prime number using recursion.

1 Answers   Aspiring Minds,


void main() { //char ch; unsigned char ch; clrscr(); for(ch =0;ch<= 127; ch++) printf(" %c= %d \t ", ch, ch); } output?

4 Answers   Groupon,


Do pointers need to be initialized?

1 Answers  


1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?

2 Answers   nvidia,


What is function and its example?

1 Answers  


program to locate string with in a string with using strstr function

2 Answers   Huawei, Shreyas,


Can you tell me how to check whether a linked list is circular?

2 Answers  


Categories