What will be the output of the following C code?
#include <stdio.h>
int main()
{
const int i = 10;
int *ptr = &i;
*ptr = 20;
printf("%d\n", i);
return 0;
}
#include <stdio.h>
int main()
{
const int i = 10;
int *ptr = &i;
*ptr = 20;
printf("%d\n", i);
return 0;
}
A. Compile time error
B. Compile time warning and printf displays 20
C. Undefined behaviour
D. 10
Answer: Option B
Join The Discussion