Comment on the output of this C code?
#include
void main()
{
int const k = 5;
k++;
printf("k is %d", k);
}
Answer: D
Constant variable has to be declared and defined at the same time. Trying to change it results in an error.
Output:
$ cc pgm12.c
pgm12.c: In function ‘main’:
pgm12.c:5: error: increment of read-only variable ‘k’