What is the output of this C code?
#include
int main()
{
const int p;
p = 4;
printf("p is %d", p);
return 0;
}
Answer: B
Since the constant variable has to be declared and defined at the same time, not doing it results in an error.
Output:
$ cc pgm10.c
pgm10.c: In function ‘main’:
pgm10.c:5: error: assignment of read-only variable ‘p’