Thursday, December 25, 2008

Constant keyword Questions with Answers in C Programming


Q1.What will be output?
void main()
{
const int a=5;
a++;


printf(“%d”,a);
}
Ans: compiler error, we cannot modify Constant variable.

Q2. 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