TCS
Company
Programming
Basics
What is the output of this C code?
#include
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%dn", k, *p, **p);
}
a) 5 5 5
b) 5 5 junk
c) 5 junk junk
d) Compile time error
Read Solution (Total 8)
-
- It will give compile time error because **p doesn't point to anything
- 6 years agoHelpfull: Yes(6) No(2)
- Compile time error
- 6 years agoHelpfull: Yes(2) No(1)
- a) is the correct answer because **p is a double pointer
- 5 years agoHelpfull: Yes(1) No(1)
- compile time error
- 5 years agoHelpfull: Yes(1) No(0)
- c is correct
- 6 years agoHelpfull: Yes(0) No(4)
- d
missing - 5 years agoHelpfull: Yes(0) No(1)
- 5 5 junk As *p=5 and **p has its address so followed by junk value.
- 5 years agoHelpfull: Yes(0) No(1)
- answer is compile time error becoz... we define address of p with pointer m and also they dont define **m in printf...
if we place int **p=&p instead of **m then it will give output as 555 - 4 years agoHelpfull: Yes(0) No(0)
TCS Other Question