What is the output of this C code? #include void main() { int k=5; int *p=&k;…
2016
What is the output of this C code?
#include
void main()
{
int k=5;
int *p=&k;
int **m=&p;
printf("%d %d %d",k,*p,**m);
}- A.
5 5 5
- B.
5 5 junk
- C.
5 junk junk
- D.
Compile time error
Attempted by 382 students.
Show answer & explanation
Correct answer: A
The code initializes k to 5, p as a pointer to k, and m as a pointer to p. Dereferencing *p gives the value of k (5). Dereferencing **m accesses the same memory location through two levels, also yielding 5. Thus, the output is '5 5 5'.