Sunday, November 23, 2008

Const keyword example with explanation in c

1>void main()
{
const int a=5;
a++;


printf(“%d”,a);
}
What will be output?
Ans: compiler error, we cannot modify const variable.
(5) What is meaning of the declaration:
const volatile int a=6;
Ans:
Value of variable cannot be changed by program (due to const) but its value can be changed by external device or hardware interrupt (due to volatile).

No comments:

Blog List